I've been attempting to configure mod_wsgi for 2 days but still no luck. Here's what Used to do:
- Produce a sample django project
python manage.py runserverand make certain it's working
mysite.wsgias well as an empty
Content of apache_django_wsgi.conf:
WSGIPythonHome /usr/bin WSGIRestrictStdout Off WSGIDaemonProcess django WSGIProcessGroup django Alias /site_media/ "/Users/Garth/Dev/web-app/mysite/media/" <Directory "/Users/Garth/Dev/web-app/mysite/media"> Order allow,deny Options Indexes Allow from all IndexOptions FancyIndexing </Directory> Alias /media/ "/Library/Python/2.6/site-packages/django/contrib/admin/media/" <Directory "/Library/Python/2.6/site-packages/django/contrib/admin/media"> Order allow,deny Options Indexes Allow from all IndexOptions FancyIndexing </Directory> WSGIScriptAlias /mysite "/Users/Garth/Dev/web-app/mysite/apache/mysite.wsgi" <Directory "/Users/Garth/Dev/web-app/mysite/apache"> Allow from all </Directory>
Content of mysite.wsgi
import os import sys sys.path.append('/Users/Garth/Dev/web-app/mysite') sys.path.append('/Users/Garth/Dev/web-app') os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()
- Download mod_wsgi.so (precompiled binary for Mac OS X) and set it in /usr/libexec/apache2
- Edit /etc/apache2/httpd.conf,
LoadModule wsgi_module libexec/apache2/mod_wsgi.so
sudo apachectl -k start
Basically visit localhost, I can tell the files and sites list. But when Time passes to localhost/mysite (the WSGIScriptAlias I set up), I acquired
Internal Server Error.
The mistake_log of apache is:
[Fri May 13 11:10:38 2011] [warn] Init: Session Cache is not configured [hint: SSLSessionCache] [Fri May 13 11:10:38 2011] [notice] Digest: generating secret for digest authentication ... [Fri May 13 11:10:38 2011] [notice] Digest: done [Fri May 13 11:10:38 2011] [notice] Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8l DAV/2 mod_wsgi/3.3 Python/2.6.1 configured -- resuming normal operations [Fri May 13 11:10:50 2011] [error] [client ::1] mod_wsgi (pid=10921): Target WSGI script '/Users/Garth/Dev/web-app/mysite/apache/mysite.wsgi' cannot be loaded as Python module. [Fri May 13 11:10:50 2011] [error] [client ::1] mod_wsgi (pid=10921): Exception occurred processing WSGI script '/Users/Garth/Dev/web-app/mysite/apache/mysite.wsgi'. [Fri May 13 11:10:50 2011] [error] Traceback (most recent call last): [Fri May 13 11:10:50 2011] [error] File "/Users/Garth/Dev/web-app/mysite/apache/mysite.wsgi", line 1, in <module> [Fri May 13 11:10:50 2011] [error] import os [Fri May 13 11:10:50 2011] [error] ImportError: No module named os
Does anybody see where goes completely wrong? The mistakerecord appears to inform a great deal. I am a new comer to web design, and that i may have made some apparent mistakes. Thanks greatly!
Don't set WSGIPythonHome to begin with it is not needed. It will simply be needed in a few instances which is not one of these.
Within this situation you've place it to some wrong value. By privileges the very fact it's wrong should not have triggered an issue as Python must have fallen to using correct default value, but it might not do this for whatever reason.
You may also remove the road:
as that is not required for mod_wsgi 3.3.