mod_python, apache and win32:

Jan Dries jdries at mail.com
Thu Aug 2 16:14:01 EDT 2001


Xione Wrent wrote:
> I installed the mod_python files, the ones from mod_python-2.7.4.tgz in my
> Python "Lib" directory under "Lib/mod_python-2.7.4". Then, I took the files
> that were in "Lib/mod_python-2.7.4/lib/mod_python/" and moved them up to
> just "Lib/mod_python-2.7.4", in accordance with the instructions.

In my case, I just copied it to "Lib/mod_python", i.e. without the
version number. That could be your problem.

> 
> I put the mod_python.dll file in my "Apached/modules" directory, and added
> "LoadModule python_module modules/mod_python.dll" in my DSO section under
> httpd.conf.

Looks OK to me.

> I think this is where I'm messing up, but I don't know. Where do I put this,
> according to these instuctions?
> 
>    Add the following lines in the section ScriptAlias and CGI of the
> httpd.conf:
> 
>    <Directory "<Your Document Root>">
>       AddHandler python-program .py
>       PythonHandler mptest
>       PythonDebug on
>    </Directory>
> 
> I don't know exactly where it's talking about.

I use a slightly different configuration:

<Location /psp>
    SetHandler python-program
    PythonHandler mod_python.modpythonhandler
    PythonDebug on
    Allow from all
</Location>

The difference is that in my case, mod_python is triggered whenever
there's a "psp" in your URL, as in "http://localhost/psp/whatever". In
my handler I then use the "whatever" part to determine the python
program to execute.

You need a piece of python code (in a file "modpythonhandler.py" in your
directory "Lib\mod_python") that looks like this:


from mod_python import apache

def handler(req):
    req.send_http_header()
    req.write("<html><body>Hello World!</body></html>")
    return apache.OK


This is the simplest handler, but enough to get things running. Once it
displays "Hello world" in your browser, you can add complexity at will.
The handler code gets executed whenever you point your browser to a url
that has /psp in it 

> Could anyone who has mod_python working under Win32 share with me their
> configuration? I'd be glad to repay you with hugs!

The above works for me. I hope it is of some help to you.

Regards,
Jan




More information about the Python-list mailing list