[mod_python] Still displaying source instead of results...

Gustavo Córdova Avila gustavo.cordova at q-voz.com
Sat Dec 4 11:37:55 EST 2004

Anthony M. Saffer wrote:

>Hello Everyone,
>I asked this question a few weeks ago and didn't receive any answer aside
>from "well, did you read the docs". So, before someone asks that again: yes
>I did read the docs here and I have done as they've told me and it still
>isn't working.
>Here's my setup:
>mod_python 2.7
>apache 1.3
>RH Linux Advanced Server (Current Version)
>I followed the following procedure to install mod_python:
>make install
>All standard stuff...The installation process told me all was well and that
>I should point add LoadModule python_module /usr/lib/apache/mod_python.so to
>the LoadModule list and AddModule mod_python.c to my AddModule list since I
>do use the ClearModuleList directive.
>Additionally, I added the following lines to my httpd.conf file right under
>the AddModule list:
>AddHandler mod_python .py
>PythonHandler mptest
>PythonDebug On
>This is ALL that the docs tell me to do and, yet, when I run the following
>script I get a dump of the source. The script is not executing even though
>I've gone as far as to chmod +x the script.
>from mod_python import apache
>def handler(req):
>    req.send_http_header()
>    req.write("Hello World!")
>    return apache.OK
>Can anyone help me out here? I am fairly new to installing new Apache
>modules and would greatly appreciate it.
Did you set PythonPath to the location where your test
module is?

Try this apache setup, it's my preferred way of using python
modules, because of the nicer urls; I use Apache 2.x and
mod_python 3.1.3, but the setup isn't much different:

<Location /py-test>
    SetHandler python-program
    PythonPath "[\"/path/to/where/your/module/is\"]+sys.path"
    PythonInterpreter py_test
    PythonHandler name_of_your_module
    PythonAutoReload On
    PythonDebug On

When you try to access any location inside /py-test from your
browser, your module gets invoked.

It's wierd, working with locations instead of directories,
but in the end it's much more flexible. IMO, of course.

Good luck with your installation.


More information about the Mod_python mailing list