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:
cd /usr/local/src
wget http://apache.mirrors.pair.com/httpd/modpython/mod_python-3.1.4.tgz
tar zxvf mod_python-3.1.4.tgz - Configure & install mod_python
cd mod_python-3.1.4
./configure --with-apxs=/usr/sbin/apxs (check where your apxs is by typing: locate apxs)
make
make install - Configure Apache:
vi /etc/httpd/conf.d/pyhton.confLocate 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:
mkdir python
Now open vi and write the following lines:
AddHandler python-program .pyn
PythonHandler testingpython
PythonDebug Osave the file as .htaccess.
Now open up vi again and copy/paste the following lines:
from mod_python import apachedef handler(req):
req.send_http_header()
req.write("Hello World!")
return apache.OKclose 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.