1

I seem to have a problem deploying django with mod_wsgi. In the past I've used mod_python but I want to make the change. I have been using Graham Dumpleton notes here http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango1, but it still seem to not work. I get a Internal Server Error.

django.wsgi file:

import os
import sys

sys.path.append('/var/www/html')
sys.path.append('/var/www/html/c2duo_crm')

os.environ['DJANGO_SETTINGS_MODULE'] = 'c2duo_crm.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

WSGIScriptAlias / /var/www/html/c2duo_crm/apache/django.wsgi

Apache httpd file:

<Directory /var/www/html/c2duo_crm/apache>
Order allow,deny
Allow from all
</Directory>

In my apache error log, it says I have this error This is not all of it, but I've got the most important part:

[Errno 13] Permission denied: '/.python-eggs'
[Thu Mar 03 14:59:25 2011] [error] [client 127.0.0.1]
[Thu Mar 03 14:59:25 2011] [error] [client 127.0.0.1] The Python egg cache directory is currently set to:
[Thu Mar 03 14:59:25 2011] [error] [client 127.0.0.1]
[Thu Mar 03 14:59:25 2011] [error] [client 127.0.0.1]   /.python-eggs
[Thu Mar 03 14:59:25 2011] [error] [client 127.0.0.1]
[Thu Mar 03 14:59:25 2011] [error] [client 127.0.0.1] Perhaps your account does not have write access to this directory?  You can
[Thu Mar 03 14:59:25 2011] [error] [client 127.0.0.1] change the cache directory by setting the PYTHON_EGG_CACHE environment
[Thu Mar 03 14:59:25 2011] [error] [client 127.0.0.1] variable to point to an accessible directory.

2 Answers 2

1

Python Eggs are module files that are contained within zip files. The Python Egg Cache is the directory where Python extracts them so it can run them. Currently you are trying to extract them to /.python-eggs but you don't have write access to either that directory, or to / if it doesn't exist.

You have two options, you can either create /.python-eggs and make it world writable (or at least writable by the user Apache is running as), or you can set PYTHON_EGG_CACHE (using the WSGIPythonEggs directive) to a directory where you do have write access.

Sign up to request clarification or add additional context in comments.

4 Comments

I remember having the same problem when I tried deploying using mod_python. What I did was I had SetEnv PYTHON_EGG_CACHE /tmp in my httpd file, and this would work. However this does not work with mod_wsgi.
Did you try using the WSGIPythonEggs directive I linked to? If the error message doesn't mention /tmp then the environment variable isn't being recognised.
Putting WSGIPythonEggs /tmp in the apache htppd file has seem to make it work. Thanks
The WSGIPythonEggs directive only works for embedded mode, not daemon mode. For way of setting it in WSGI script file, see documentation at 'code.google.com/p/modwsgi/wiki/…'. BTW, you should preferably use daemon mode.
1
# Avoid [Errno 13] Permission denied: '/var/www/.python-eggs' messages
import os

os.environ['PYTHON_EGG_CACHE'] = '/tmp'

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.