How to install Mod_Python in Linux server
April 29, 2008 | In: Installation, Python
Both 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
wget http://www.trieuvan.com/apache/httpd/modpython/mod_python-2.7.11.tgz
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:
CFLAGS=$(OPT) $(INCLUDES) -DEAPI
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/mod_python.so
AddModule mod_python.c
AddHandler mod_python .psp .py
Apache 2.1.x
LoadModule python_module modules/mod_python.so
AddHandler mod_python .psp .py





2 Responses to How to install Mod_Python in Linux server
Sander
November 7th, 2008 at 1:40 pm
Hi there
My apache directory
/usr/lib/apache/
Do i need to change this rule *?
./configure –with-apxs=/usr/local/apache/bin/apxs –with-python=/usr/local/bin/python
* Does it mean configure Python from the one to another directory, or what? apxs?
Thank you SAnder
presoon
November 15th, 2008 at 2:20 am
Hi SAnder,
apxs is Apache extension handler.
So what you need to change is like.
./configure –with-apxs=/usr/lib/apache/bin/apxs –with-python=specify the location of python installed in your server