Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
    
Hi Phil, thanks for your comment. There are no .htaccess files in play, and I haven't changed any of the basic apache configuration files. It's actually happening on two servers - both production and staging, so I don't think it's something specific to the server configuration...? –  John McCollum Feb 10 '10 at 16:30

1 Answer 1

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

 
discard

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.