3

I currently use Apache 2.0 and FastCGI to serve my Django sites (I host multiple sites from a single server / IP). Each site has it's own FastCGI process which stops Apache forking multiple copies which can use a lot of memory and means I can restart a single Django site back end without restarting Apache.

Is this a sensible way to do things and are there other/better alternatives?

Jon Cage
  • 329
  • 1
  • 3
  • 12

3 Answers3

4

You definitely need mod-wsgi.

mod-wsgi is developed by the same brains that made mod-python many years ago. mod-wsgi is now recommended over mod-python for all modern app frameworks, including django.

Basically, mod-wsgi has two modes of operation: embedded (fastest - kind of like mod-python only faster) or daemon (kind of like fast-cgi).

In daemon mode, it is preferable to fast-cgi because:

  1. it doesn't require any additional moving parts (like flup)
  2. you don't need to stop and start the python interpreters, it's taken care of by mod-wsgi.

In embedded mode, it is preferable to mod-python because:

  1. Development of mod-python has ceased in favor of mod-wsgi
  2. mod-wsgi will eventually support python 3k.
  3. mod-wsgi is faster than mod-python

Here's the documentation: http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

/ Richy

Rich
  • 945
  • 1
  • 6
  • 15
  • Sorry, mod_python was written by Gregory Trubetskoy and he had nothing to do with mod_wsgi. – Graham Dumpleton Jun 27 '09 at 10:42
  • Oh, and mod_python development has not officially ceased. It is still a managed project of the Apache Software Foundation and if anyone wants to step in and work on it they can. – Graham Dumpleton Jun 27 '09 at 10:43
0

Early I use nginx and supervisord ( little howto on Russia http://buzzja.mine.nu/blog/2009/02/21/dzhango-za-stenoj/ )

ezotrank
  • 111
  • 1
0

I use Apache2 and mod_python with good success. You just end up adding some django-app. specific stuff to apache similar to this (example pulled from a VHost running ReviewBoard from review-board.org):

<Location "/reviewboard">
    SetHandler mod_python
    PythonPath "['/usr/lib/python2.4/site-packages/django'] + ['/usr
/local/reviewboard'] + ['/usr/local/reviewboard/djblets', '/usr/local'] + sys.pa
th"
    SetEnv DJANGO_SETTINGS_MODULE reviewboard.settings
    PythonHandler django.core.handlers.modpython
    PythonAutoReload Off
    PythonDebug Off
    PythonInterpreter reviewboard
</Location>

The important setting in this case is the uniqueness of 'PythonInterpreter' across your different django applications.

Good luck.

jharley
  • 813
  • 6
  • 10