Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having a problem setting up Django on our CentOS server using mod_python. Site 'A' is running PHP (Codeigniter) and site 'B' is running Django. Our Django site is running perfectly.

However, every once in a while (maybe 1 or 2 requests in 10), site 'A' is giving a 404 error. With further investigation, I've discovered that there are a number of server environment variables that are being set globally by Django. For example, looking at a phpinfo() page within site A:

_ENV["DJANGO_SETTINGS_MODULE"]  mysite.settings
_ENV["REQUEST_URI"] /path/to/my/django/site/page

Because all the request paths are set to my Django site URLs, Codeigniter is 404ing.

The setup in httpd.conf is that we have location tags set up within a virtualhost directive.

Can anyone help?

share|improve this question
These are more than likely being set in your Apache configuration files (or perhaps .htaccess files). You would be doing people a service by pasting those. – Philip Reynolds Feb 10 '10 at 16:18
up vote 1 down vote accepted

This may not be the answer you want to hear but here goes anyway :)

If you run your Django site under mod_wsgi instead of mod_python you will see multiple benefits:

  1. Under mod_wsgi you can run in daemon mode, meaning your Django site will be isolated in its own process. This means environment variables won't be set globally in the Apache environment (which I think in your case are being set by mod_python). It also means you can restart your Django site without restarting Apache.

  2. With mod_wsgi in daemon mode you will have only one instance of Python interpreter running in memory instead of one instance in each Apache process. This is a huge memory savings, leaving you more room for caching, more Apache processes, whatever.

  3. mod_wsgi is not just more stable, but enough that I am just one of many Django devs that slap our foreheads whenever we see someone still using mod_python. Example: tweet from Django core dev Jacob Kaplan-Moss.

  4. Finally, mod_wsgi is faster and has excellent community support, compared to zero support and languishing bugs for mod_python.

share|improve this answer
I understand that mod_python isn't an ideal platform, but for various reasons mod_wsgi isn't available. I believe FastCGI might be available though, so I'll look into that. You're right, it isn't what I wanted to hear, but thanks for your answer anyway! – John McCollum Feb 27 '10 at 23:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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