This is a simple guide to install/upgrade mod_python on a Plesk RHEL box, running Apache 2.0.x. You need to have at least Python version 2.2.1 installed for this to work.
I could not get mod_python version 3.2.8 running at the time of writing.
- Download and extract mod_python:
tar zxvf mod_python-3.1.4.tgz
- Configure & install mod_python
./configure --with-apxs=/usr/sbin/apxs (check where your apxs is by typing: locate apxs)
- Configure Apache:
Locate your LoadModule – section and add the following line under the others:
LoadModule python_module modules/mod_python.so
- Installation done, now time for testing:
First go to a publicly accessible directory. Make a test directory for mod_python by typing:
Now open vi and write the following lines:
AddHandler python-program .pyn
save the file as .htaccess.
Now open up vi again and copy/paste the following lines:
from mod_python import apache
close and save as testingpython.py. Those are tabs not spaces. If you left align everything you will get this error:
IndentationError: expected an indented block (testingpython.py, line 4)"
Now restart Apache by typing:
service httpd restart
Take your browser to www.mydomain.com/python/testingpython.py and you should see “Hello World!” If you can see this message then you have succesfully installed mod_python.