[Fixed]-Cannot solve mod_wsgi exception in Django setup

23👍

If the quoted configuration about is what you are using, the error is rather obvious actually. You have:

WSGIDaemonProcess fred threads=15 display-name=%{GROUP} python-path=/home/fred/public_html/cgi-bin/fredapp/apache/
WSGIProcessGroup scratchf

It should be:

WSGIDaemonProcess fred threads=15 display-name=%{GROUP} python-path=/home/fred/public_html/cgi-bin/fredapp/apache/
WSGIProcessGroup fred

That is, the name of the process group must match.

You should though have seen an error message:

No WSGI daemon process called 'scratchf' has been configured

This would likely be before the logged error:

Exception occurred processing WSGI script

This is why it is important that you supply all the error log messages and don’t assume that they aren’t relevant.

Alternatively, you have quoted configuration different to what you are using or not all of the configuration.


UPDATE 1

It looks like you may have ErrorDocument directive enabled in Apache to redirect errors to a specific URL. Because however you have mounted Django at root of web server and not excluded those error URLs from being passed through to Django, then when an error is generated Django gets the redirect for the error document but it cannot resolve the URL and subsequently generates a 404. Because Apache saw a 404 for error page redirect, it then returns a 500 default error page. The end result is that true original error and any information is lost.

Thus, go into Apache configuration and comment out the ErrorDocument directives.


UPDATE 2

Change configuration to:

WSGIScriptAlias /fredapp /home/fred/public_html/cgi-bin/fredapp/apache/django.wsgi

You should not have trailing slash on the second value on line. Missed that you were actually trying to mount at sub URL and not at root of web server.

1👍

Is it possible that your starting directory is not the one project is in?

Today I was also setting up Apache+mod_wsgi+Django app and after adding to django.wsgi:

 os.chdir('/home/user/my_django_project')

everything started to work like a charm.

0👍

We had the same error when the user running Apache had not the rights to read the files.

👤fylb

Leave a comment