[mod_python] Installing mod_python (newbie)

Jorey Bump list at joreybump.com
Tue Oct 18 15:58:50 EDT 2005

Philippe C. Martin wrote:

> I also noticed that the localhost/mp pages shows "Apache/2.0.55 (Unix) 
> mod_python/3.2.0b Python/2.4.2 Server at Port 80" at the bottom.

Okay, then mod_python is loaded and running. I think your test is 
flawed, however. Try something simpler:

<Directory "/var/www/html/mp">
   SetHandler python-program
   PythonHandler mod_python.publisher
   PythonDebug On

Create /var/www/html/mp/hello.py:

def world():
     return "Hello, world!"

Restart apache and point a browser at:


SetHandler causes mod_python to handle *all* files in the directory, and 
allows you to leave off the .py extension. Publisher requires you to 
point the URL at a function within the module. AddHandler lets you mix 
files, but you must call the module with the .py extension.

When using SetHandler, you can create a file named index.py with a 
function named index, and leave both off the URL. This has historically 
caused some problems that 3.2b claims to address. I've haven't checked 
this myself, but try it next if you really want to use only the 
directory in the URL with a default module/function.

More information about the Mod_python mailing list