Installing mod_python apache on windows
October 17th, 2008To install and test mod_python Apache on Windows (assuming that you’ve already had Apache and Python installed):
- Download mod_python Win32 Binaries from http://httpd.apache.org/modules/python-download.cgi
- Run the installer. When prompted for Apache installation directory, type C:\Program Files\Apache Software Foundation\Apache2.2 (Assuming default Apache installation).
- Edit httpd.conf.
- Add the following line:
LoadModule python_module modules/mod_python.so - Configure your Apache <Directory> directives to include AddHandler, PythonHandler, and PythonDebug (examples below).
To test your mod_python installation:
- Create a file named mptest.py in say C:\sites.
- The file will contain:
from mod_python import apache
def handler(req):
req.content_type = ‘text/plain’
req.write(”Hello World”)
return apache.OK - Edit httpd.conf.
- Under <Directory “C:/sites”> directive add:
AddHandler mod_python .py
PythonHandler mptest
PythonDebug On - Restart Apache and point your browser to the mptest.py url.