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.
link|improve this question

60% accept rate
Duplicate of 'stackoverflow.com/questions/5182954/…;. – Graham Dumpleton Mar 3 '11 at 21:00
feedback

2 Answers

up vote 0 down vote accepted

You can set the WSGI variable for this. In your Apache config:

WSGIPythonEggs /var/tmp

This is the same as setting the PYTHON_EGG_CACHE environment variable which, as pointed out in topdog's answer, only works with mod_python.

link|improve this answer
1  
That only works for embedded mode of mod_wsgi, not daemon mode. For daemon mode you use the python-eggs option to WSGIDaemonProcess. You shouldn't be using embedded mode unless you have a good reason to or are on Windows where you have no choice. Only way that works for both modes is to do it in the WSGI script file. – Graham Dumpleton Mar 5 '11 at 10:36
Based on his config, he's using embedded mode. Obviously, you're the expert on mod_wsgi... seeing as you wrote it. :) Can't than you enough for doing so! – Andrew M. Mar 5 '11 at 16:52
Yep, saw that he was likely using embedded mode. Just wanted to clarify it so people coming and reading the post later didn't think that directive universally applied across both modes. – Graham Dumpleton Mar 7 '11 at 15:35
feedback

Set this in your apache configuration

SetEnv PYTHON_EGG_CACHE /var/tmp
link|improve this answer
funny, still does not work & same still get error – Shehzad009 Mar 3 '11 at 16:15
2  
The SetEnv method only works for mod_python and even then only for certain configurations. – Graham Dumpleton Mar 3 '11 at 20:58
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.