[mod_python] Getting mptest.py to work

Graham Dumpleton grahamd at dscpl.com.au
Wed Jan 19 05:28:16 EST 2005


On 19/01/2005, at 9:13 PM, Johann Spies wrote:

> This is my first question on the list.  I have seen messages in the
> archive (using google) asking the same thing, but nothing that
> indicated a solution.
>
> My system:  Debian Sid with
>
> libapache2-mod-pyth 3.1.3-2.2
> apache2             2.0.52-3
> python2.3           2.3.4-19
>
>
> I have created /var/www/test with the following files:
>
> .htaccess:
>
> <Directory /var/www/test/>
>    AddHandler mod_python .py
>    PythonHandler mptest
>    PythonDebug On
> </Directory>
>

If you are configuring things in the .htaccess file, you do not need the
<Directory> directive around the statements. Ie., use just:

   AddHandler mod_python .py
   PythonHandler mptest
   PythonDebug On

Start with making that change, if still no luck, restart Apache and look
in its error log file to see what it produces on startup, you should see
something like:

   [Wed Jan 19 21:25:33 2005] [notice] mod_python: Creating 32 session 
mutexes based on 6 max processes and 25 max threads.
   [Wed Jan 19 21:25:34 2005] [notice] Apache/2.0.51 (Unix) 
mod_python/3.1.3 Python/2.3 configured -- resuming normal operations

I am using threads, if just using prefork then the messages will be 
different.
The point is though that you should see something there by mod_python.

If you don't even see that, mod_python not being loaded. If it wasn't 
being
loaded, the request against directory with above .htaccess file would 
most
like return a 500 internal server error.

> and
>
> mptest.py:
>
> from mod_python import apache
>
>
> def handler(req):
>     req.content_type="text/html"
>     req.write("Hello World!")
>     return apache.OK
>
>
>  I have added the 'req.content_type="text/html"' part after a
>  suggestion somewhere to a user with a similar problem than mine, but
>  that did not make any difference.
>
> Apache does not produce any error message about this setup.  It just
> does not use mod-python and Firefox does not know what to do with the
> file mptest.py
>
> O, and I have this in /etc/apache2/mods-enabled:
>
> drwxr-xr-x  8 root root 4096 2005-01-18 16:22 ..
> lrwxrwxrwx  1 root root   38 2005-01-18 16:34 cache.load -> 
> /etc/apache2/mods-available/cache.load
> lrwxrwxrwx  1 root root   37 2005-01-18 16:22 cgid.conf -> 
> /etc/apache2/mods-available/cgid.conf
> lrwxrwxrwx  1 root root   37 2005-01-18 16:22 cgid.load -> 
> /etc/apache2/mods-available/cgid.load
> lrwxrwxrwx  1 root root   33 2005-01-18 16:36 mod_python.load -> 
> ../mods-available/mod_python.load
> lrwxrwxrwx  1 root root   43 2005-01-18 16:22 proxy_html.load -> 
> /etc/apache2/mods-available/proxy_html.load
> lrwxrwxrwx  1 root root   40 2005-01-18 16:32 rewrite.load -> 
> /etc/apache2/mods-available/rewrite.load
> lrwxrwxrwx  1 root root   40 2005-01-18 16:22 userdir.conf -> 
> /etc/apache2/mods-available/userdir.conf
> lrwxrwxrwx  1 root root   40 2005-01-18 16:22 userdir.load -> 
> /etc/apache2/mods-available/userdir.load
> lrwxrwxrwx  1 root root   44 2005-01-18 16:33 vhost_alias.load -> 
> /etc/apache2/mods-available/vhost_alias.load
>
>
> How do I progress from here?
>
> Regards
> Johann
>
> -- 
> Johann Spies          Telefoon: 021-808 4036
> Informasietegnologie, Universiteit van Stellenbosch
>
>      "The LORD is my strength and song, and he is become my
>       salvation; he is my God, and I will prepare him an
>       habitation; my father's God, and I will exalt him."
>                        Exodus 15:2
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list