mod_python grief

Posted by Graham Stratton Thu, 10 Aug 2006 00:27:11 GMT

I decided that I wanted to put a Pylons application behind Apache. After the grief I had with Rails, I wasn’t keen to use fcgi. So I decided to try the mod_python approach, which is generally significantly faster anyway.

Since a Pylons app is a WSGI app, this should be trivial. The first thing to do was to install mod_python, a standard download, configure, compile and install. Then the WSGI app must be made suitable for deployment via mod_python. There is a project to create a mod_python gateway, but for some reason this wasn’t included in the latest version of mod_python. So I downloaded it, and saved it as mod_python/wsgi.py.

Then I created a two-liner python program startup.py:

from paste.deploy import loadapp
app = loadapp("config:/home/graham/flightsearch/deployment.ini")

Then I had to configure apache.

<Location /flightsearch>
  SetHandler mod_python
  PythonHandler mod_python.wsgi
  PythonPath "['/home/graham/flightsearch'] + sys.path" 
  PythonOption wsgi.application startup::app
</Location>

I did all this and, erm, it didn’t work. In fact, I had segmentation faults in my Apache error log. A lot of Googling suggested a lot of possible reasons. It turned out to be that Apache uses the version of libexpat installed on the system, whereas python 2.4 ships with its own (later) version. This could just be an issue because the system is old (Fedora Core 1). Anyway, for some reason replacing the libraries on the system with the same version as python was using, and sym-linking them appropriately was enough to get things working.

Finally, Apache needs to be given access to some data and lock files associated with the application.

Posted in , ,  | no comments

Comments

(leave url/email »)

   Comment Markup Help Preview comment