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.
Shehzad009
  • 147
  • 1
  • 2
  • 6

3 Answers3

0

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.

Andrew M.
  • 11,182
  • 2
  • 35
  • 29
  • 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 05 '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 05 '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 07 '11 at 15:35
0

This could be a SELInux permissions problem. Is this RedHat Linux or a RedHat variant (CentOS or Scientific Linux for example)? If so you may need to either disable SELinux (not generally recommended) or set the file context of the directory. Debian (and variants) disable SELinux by default but RedHat and CentOS have it enabled by default.

For any file/directory you read/write you can use this command to change the file context:

sudo chcon system_u:object_r:httpd_sys_rw_content_t:s0 (upload folder name)

This posting I gave from my experience with mod_wsgi compile/install may be useful:

Getting compiled Python mod_wsgi module working on Apache server with SElinux enforcing mode. Let me know if any of htis helps.

-1

Set this in your apache configuration

SetEnv PYTHON_EGG_CACHE /var/tmp
topdog
  • 3,520
  • 17
  • 13