[mod_python] Getting mptest.py to work

Graham Dumpleton grahamd at dscpl.com.au
Wed Jan 19 14:33:40 EST 2005


On 19/01/2005, at 11:21 PM, Johann Spies wrote:

> Dear Graham,
>
> Thanks for your patience and help.  As you can see I have a lot to
> learn about apache and related products.
>
> On Wed, Jan 19, 2005 at 10:03:44PM +1100, Graham Dumpleton wrote:
>>
>> Do a sanity check to see if the .htaccess file is actually being read.
>> One can use another feature of mod_python to check this. Add:
>>
>>   PythonOption Name
>>
>> If mod_python is working okay and the .htaccess file is being read,
>> this should cause a 500 server error to be returned as a value for
>> option hasn't been supplied.
>
> This did not produce any error or success.

I can only guess then that the permissions on the .htaccess file
didn't include read access to others. The file needs to be readable
by the user Apache runs under. This isn't usually root so the file
needs to be readable to others or have group membership and readership
for group that Apache runs as.

>>
>> If you don't see this, then might be that main httpd.conf file not
>> configured to allow .htaccess in that part of directory hierarchy,
>> although, not sure if that is possible.
>>
>> Next step might be to use the original <Directory> directive block
>> you had and put it in the main httpd.conf in an appropriate spot
>> to see if that makes a difference.
>
> So I  created a file in /etc/apache2/sites-enabled with the following
> content:
>
> <Directory /var/www/test/>
>    AddHandler mod_python .py
>    PythonHandler mptest
>    PythonDebug On
> </Directory>
>
> And now I get the 500 server error when I click on mptest.py (just in
> the browser - nothing in /var/log/apache2/error.log) after a
> considerable period of time. Going just to http://localhost/test/
> results in a directory being displayed with no error message.
>

Use:

   http://localhost/test/foo.py

Only requests which have a ".py" extension will be routed through the
handler. Ie., the "foo" bit doesn't matter as long as ends in ".py".

To have directory access also, or any extension for that matter, map
to handler, you need to look at using "SetHandler" instead of
"AddHandler" Ie.,

   SetHandler mod_python




More information about the Mod_python mailing list