Apache Server giving Error 500 without error_log

30 views
Skip to first unread message

Olaf Yang

unread,
Oct 23, 2020, 9:57:39 PM10/23/20
to modwsgi

I am trying to get a django app to run on amazon linux 2. After installing apache server by yum and compiling mod_wsgi from source. I configured mod_wsgi according to the quick installation guide on the documentation. I've also followed this guide from django. There is also a " Apache/2.4.46 () mod_wsgi/4.7.1 Python/3.9  configured -- resuming normal operations" entry  in error_log. However, every time I visit the ip address it gives me a "Server Error(500)". There are no other significant entries in error_log to indicate the issue.

I will post my apache server configuration bellow:
I have only added from line 33 to 55

https://pastebin.com/N7pvEvzx

the / switchsnap .net/ is my project root (where manage.py is) and wsgi.py is stored in switchsnap .net/switchsnap

I wish someone can help me pin down the issue.
Thanks in advance.


Graham Dumpleton

unread,
Oct 23, 2020, 10:04:59 PM10/23/20
to mod...@googlegroups.com
You need to work out, or indicate whether the 500 error is from Apache or Django.

Use:

    LogLevel info

not "warn", so you can see whether mod_wsgi is even loading your WSGI script file or whether you issue is with your Apache configuration.

If it is loading the Django application, then temporarily enable DEBUG in Django settings file so that Django reports the error in the browser. This is necessary as Django will not log errors to the log unless you have set up Django logging to do that.

If you believe the Apache configuration is fine, replace the WSGI script file with a WSGI hello world application instead of Django to see if you get a response from that.

def application(environ, start_response):
    status = '200 OK'
    output = b'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

Finally, you also are putting the config in Apache config in the wrong place.

The LoadModule line should go after other LoadModule lines.

The mod_wsgi configuration directives would then usually go at the end of the configuration, or inside the VirtualHost the need to apply to if one is defined. I am actually surprised that Apache even starts with where you have put the configuration.

Graham

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/666fe9af-16ff-4815-8e83-72996bf6190bn%40googlegroups.com.

Olaf Yang

unread,
Oct 23, 2020, 10:36:17 PM10/23/20
to modwsgi

Thank you for your guide in troubleshooting. After enabling DEBUG in django, I found out that the cause of this issue is in falsely configured TEMPLATES_DIR. So it's comming from django. I have since fixed the issue.
As a first time developer, I am really thankful for your help and your guidance in configuring apache.
 
Reply all
Reply to author
Forward
0 new messages