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 , ,  | 2 comments

Comments

  1. Power Transmission said 1385 days later:

    Thanks for your information

  2. Contact Center said 1394 days later:

    Apache is a web server and it provides a key role in the growth of World Wide Web. Python applications are used to run behind the apache. Python is a programming language that makes the system more fast and it has lower maintenance cost. Python is free to use and it has an open source license. The first step is to install the mod-python. The main aim of this project is to create a mod-python gateway. If the latest version of the python is not there, then go through web and download the newer version of python. After downloading it is saved as mod_python/wsgi.py.

(leave url/email »)

   Comment Markup Help Preview comment