The issue I'm having is my wsgi file can't import the wsgi handlers properly.
/var/log/apache2/error.log
reports:
ImportError: No module named django.core.handlers.wsgi
Googling this brings up a couple results, mostly dealing with permissions errors because www-data
can't read certain files and/or the pythonpath is not correct. Some of the solutions are vague or just don't work in my circumstance.
Background information..
My /usr/lib directory..
/usr/lib/python2.4
/usr/lib/python2.5
/usr/lib/python2.6
/usr/lib/python-django
The default python version is 2.5.2. If I open the interpreter as a regular user I can import django.core.handlers.wsgi
with no issues.
If I switch to www-data
the python version is the same, and I can import the django.core.handlers.wsgi
module no problem.
In my bashrc, I set my PYTHONPATH to my home directory which contains all my django sites...
export PYTHONPATH=/home/meder/django-sites/:$PYTHONPATH
So the directory structure is:
django-sites/
test
test
is the directory created by django-admin createproject
.
My virtualhost:
<VirtualHost *:80>
ServerName beta.blah.com
WSGIScriptAlias / /home/meder/django-sites/test/apache/django.wsgi
Alias /media /home/meder/django-sites/test/media/
</VirtualHost>
The /home/meder/django-sites/test/apache/django.wsgi
file itself:
import os, sys
sys.path.append('/usr/local/django')
sys.path.append('/home/meder/django-sites')
sys.path.append('/home/meder/django-sites/test')
os.environ['DJANGO_SETTINGS_MODULE'] = 'test.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
Finally, my OS is Debian Lenny and I grabbed django 1.1.1 from backports. Hope that's enough information.
Update #1 - per the first reply here's the result of ldd /usr/lib/apache2/modules/mod_wsgi.so
:
meder@site:/usr/lib/apache2/modules$ ldd mod_wsgi.so
libpython2.5.so.1.0 => /usr/lib/libpython2.5.so.1.0 (0xb7d99000)
libpthread.so.0 => /lib/libpthread.so.0 (0xb7d81000)
libdl.so.2 => /lib/libdl.so.2 (0xb7d7c000)
libutil.so.1 => /lib/libutil.so.1 (0xb7d78000)
libm.so.6 => /lib/libm.so.6 (0xb7d52000)
libc.so.6 => /lib/libc.so.6 (0xb7c14000)
/lib/ld-linux.so.2 (0xb7efd000)
So it is compiled against python 2.5 and not 2.4.