I'm setting up Apache2 and mod_wsgi for Django in Debian, but I found problems. First, these are my directories:
/webapps/lib/python2.6/site-packages # python eggs
/webapps/lib/python2.6/ # python libraries
/webapps/myproject.wsgi # wsgi script
/webapps/myproject/ # django project
And this is the directory /webapps/lib/python2.6
(permissions are 777):
.
├── django
│ ├── bin
│ ├── conf
│ ├── ...
│ └── views
└── site-packages
├── easy-install.pth
├── mongoengine-0.5.3-py2.6.egg
├── pymongo-2.1-py2.6-linux-x86_64.egg
└── site.py
In httpd.conf
I have this:
WSGIScriptAlias / /webapps/myproject.wsgi
WSGIPythonEggs /webapps/lib/python2.6/site-packages/
And finally in myproject.wsgi
:
import sys
sys.path.insert(0, '/webapps/lib/python2.6/site-packages')
sys.path.insert(0, '/webapps/lib/python2.6')
sys.path.insert(0, '/webapps/myproject')
.. Nothing important
# I tried 2 lines above as well, but nothing
#import os
#os.environ["PYTHON_EGG_CACHE"] = "/webapps/lib/python2.6/site-packages"
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()
# This for trying if system reads eggs
try:
import mongoengine
except Exception as e:
raise ImportError(str(e) + ". " + str(sys.path))
When I restart Apache and try to visit any webpage, I get error 500 and this in the log:
[Wed Jan 04 18:18:12 2012] [error] [client 217.217.164.22] ImportError: No module named mongoengine. ['/webapps/myproject', '/webapps/lib/python2.6', '/webapps/lib/python2.6/site-packages', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/local/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages', '/usr/lib/pymodules/python2.6']
So as you can see django is imported well, but none of the eggs are imported. However I didn't find any other way to import them. Why eggs are not imported?
Thanks.