I've been wanting to drop mod_python since the day I installed it. After the saga of setting it up, I was left feeling unclean. So I sat down yesterday and started downloading new versions of stuff. Apache, mod_fastcgi, Python, Subversion, PHP… you name it. My biggest concerns were upgrading to Python 2.5, and switching this site (and others) from mod_python to mod_fastcgi. But I sure am glad I did. Deploying a Django site was never my favorite thing to do under mod_python, but with mod_fastcgi, it became an almost joyous experience.

Here's the VirtualHost entry for this site running under mod_python:

<VirtualHost *:80>
    ServerName theidioteque.net
    ServerAlias www.theidioteque.net
    <Location />
        SetHandler python-program
        PythonPath "['/home/dcwatson/projects'] + sys.path"
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE idioteque.settings
        PythonDebug Off
    </Location>
    Alias /static /home/dcwatson/projects/idioteque/static
    <Location /static/>
        SetHandler None
    </Location>
</VirtualHost>

And here it is running under mod_fastcgi:

<VirtualHost *:80>
    ServerName theidioteque.net
    ServerAlias www.theidioteque.net
    Alias /static /home/dcwatson/webapps/idioteque/static
    ScriptAlias / /home/dcwatson/webapps/idioteque.fcgi/
</VirtualHost>

Note the trailing slash at the end of the .fcgi script. Forget it, and your links won't work. My idioteque.fcgi script looks just like the one found on django's fastcgi documentation.

Setting up trac was just as easy. I simply copied the trac.fcgi script to my own trac-idioteque.fcgi script and set the TRAC_ENV environment variable at the top of it, as described here. Now my VirtualHost entry is three lines:

<VirtualHost *:80>
    ServerName code.theidioteque.net
    Alias /chrome/common /usr/local/python/share/trac/htdocs
    ScriptAlias / /home/dcwatson/webapps/trac-idioteque.fcgi/
</VirtualHost>

I should probably note that I have Allow from all set in my root Directory in httpd.conf. This is probably not a terribly good idea, but it saves explicitly allowing access to any directory I want to serve files from.

Apologies for the particularly dry post, but if you haven't noticed, this blog seems to be geared around problems I encounter and my solutions to them. If your problem is mod_python, mod_fastcgi is your solution.