Installing Mod_Python

Update: These instructions may be outdated for most people. I’ve posted newer instructions on my collaborated sister site:

I figured I’d put this out here because it’s come up quite recently with people who are using Apache 1.3.x. If you haven’t gotten the balls to upgrade to Apache 2.x yet, you can still install mod_python…just not as easily. This simple walk through is for Apache 1.x and 2.x.

First, you need to determine what version of Python you are running. To check, type ‘python -V‘ at the command line. If you are running Apache 1.3.x, you should use mod_python version 2.7.11. For Apache 2.2.x, use 3.3.1.

1. Download the Python sources for the version of Python that you have installed, the run a configure and make (no install) just to compile them. If you are running Apache 1.3, you should add –without-threads to your configure line.

2. Once you have this, follow these steps to compile mod_python:

cd /usr/src
tar -xvzf mod_python-2.7.11.tgz
cd mod_python-2.7.11

./configure –with-apxs=/usr/local/apache/bin/apxs –with-python=/usr/src/Python2.5.5

The –with-python path should reflect the location of the sources you downloaded and compiled earlier.

3. If you are on Apache 1.3, you now need to perform the steps below. If not, skip to step 4:

pico src/Makefile

Locate the ‘CFLAGS’ line, and add the -DEAPI switch so it looks like this:


Then add -lutil to the LIBS line like so:

LIBS=-lm /usr/src/Python-2.5.1/libpython2.5.a -lutil

4. Run the make and make install.

5. Now edit httpd.conf and create your handlers. This will tell Apache which file extensions to interpret through mod_python. If you have mod_rewrite installed and enabled, users can override this in their .htaccess files:

LoadModule python_module libexec/
AddModule mod_python.c
AddHandler mod_python .psp .py

Be Sociable, Share!

Leave a Reply

Your email address will not be published. Required fields are marked *