Loading Mod_Python on Apache 2.x on CentOS 4.x and CentOS 5.x

Loading Python on Apache is easy. The material is taken from Mod Python ArchLinux Wiki

Configure Apache
# vim /etc/httpd/conf/httpd.conf

LoadModule python_module modules/mod_python.so

Restart Apache
# service restart httpd

Test Mod_Python
1. Add this block to /etc/httpd/conf/httpd.conf
<Directory /home/www/html> 
AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On
</Directory>

2. Create a file in /home/www/html/ called mptest.py and add this as contents

from mod_python import apache
def handler(req):
req.content_type = 'text/plain'
req.send_http_header()
req.write("Hello World!")
return apache.OK

Restart Apache again
# service restart httpd

Navigate to http://www.yoursite.com/mphandler.py/handler and you should see a site that says
Hello World!