I'm attempting to deploy mod_wsgi with apache to operate a django application but I get a mistake 500 internal server error The apache logs shows:
[Thu Jun 23 14:01:47 2011] [error] [client 126.96.36.199] mod_wsgi (pid=16142): Exception occurred processing WSGI script '/home/user/bms/apache/django.wsgi'. [Thu Jun 23 14:01:47 2011] [error] [client 188.8.131.52] Traceback (most recent call last): [Thu Jun 23 14:01:47 2011] [error] [client 184.108.40.206] File "/home/user/bms/apache/django.wsgi", line 13, in <module> [Thu Jun 23 14:01:47 2011] [error] [client 220.127.116.11] import django.core.handlers.wsgi [Thu Jun 23 14:01:47 2011] [error] [client 18.104.22.168] ImportError: No module named django.core.handlers.wsgi
My apache virtual host is the following:
<VirtualHost *:80> DocumentRoot /home/user/bms <Directory /home/user/bms> Order allow,deny Allow from all </Directory> WSGIDaemonProcess bms user=user group=user processes=2 threads=25 python-path=/usr/local/lib/python2.7/site-packages WSGIProcessGroup bms WSGIScriptAlias / /home/user/bms/apache/django.wsgi </VirtualHost>
And also the recommended wsgi file during my application directory with 0777 permissions:
import os import sys path = '/home/user/bms' if path not in sys.path: sys.path.append(path) os.environ['DJANGO_SETTINGS_MODULE'] = 'bms.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()
I heard this might be since the apache user doesn't have the right permissions. However have no clue how you can fix this. I additionally attempted beginning the deamon using the www-data user which didn't solve the problem.
I solved this by copying the virtual hosts file in to the default one after which crippling that old one with a2dissite. I've no clue the way i can perform it "correctly" and hang it so apache would go to the virtual host I would like it to though.
It'll set you straight on the couple of things including permissions as well as about establishing sys.path properly inside your WSGI script, the second much more likely being your condition.
Have you check it out with no WSGIDaemonProcess option?
I'd little difficulty establishing mod_wsgi in your own home, but made it happen with no daemon option. You pointed out fixing by getting around virtual hosts files and that i note this caveat within the paperwork for WSGIDaemonProcess:
Also observe that the title from the daemon process group should be unique for that whole server. That's, it's not easy to make use of the same daemon process group title in various virtual hosts.
Have no idea if that is coincidence.