Install Mod_Python in Linux server

Instruction for Apache 1.x and Apache 2.x are given below

First, you need to check what version of Python you are running.

python -V

If you are running Apache 1.3.x, you should use mod_python version 2.7.11 and for Apache 2.2.x, use 3.3.1.

Python with version 2.1.x greater than are only supported
latest is to use Python2.5.5

The step are for Apache 1.3.x. However, for Apache 2.1.x download mod_python 3.3.1 and follow the same steps

cd /usr/local/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/local/bin/python

The –with-python path should reflect the location of the python binary

If you are on Apache 1.3, follow the steps below. If not, go for make and make install.

vi 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/local/src/Python-2.5.1/libpython2.5.a -lutil

Run the make and make install.

This should be done. for both Apache versions.

Edit httpd.conf and create your handlers.

Apache 1.3.x
LoadModule python_module libexec/
AddModule mod_python.c
AddHandler mod_python .psp .py

Apache 2.1.x
LoadModule python_module modules/
AddHandler mod_python .psp .py