mod_python configuration and debugging
If you are (smart || lucky) enough to have your own server to ‘hose’ you will be able to view your mod_python configuration fairly easily for debugging or information reasons by adding two lines to your .htaccess file. For obvious security reasons you will want to only enable this configuration temporarily.
The mod_python module will already need to be available through the Apache HTTP server. If you are having trouble installing mod_python, this will not help you. I can say that I have compiled and installed mod_python on both Mac OS X Tiger 10.4.11 and Mac OS X Leopard 10.5.2 without issue. Just stick to the instructions and everything will end up okay (except for the 3rd-party software you installed last week but completely forgot about, that's wrecked).
Save the two lines of code below into a .htaccess file or to a <Directory> configuration section within Apache's main configuration file normally named httpd.conf. Place the .htaccess file into an empty directory such as ‘config’ or ‘test’.
# mod_python debug and info
SetHandler mod_python
PythonHandler mod_python.testhandler
Navigate to the page and you will find the output is not unlike using the PHP function phpinfo() for displaying PHP server configuration information.
Python will output all kinds of information including modules installed, system and software versions, and the ability to view the last 100 lines of the httpd error file connected to the server that handles the mod_python request.
Example:
General information
Apache version Apache/2.2.0 (FreeBSD) DAV/2 PHP/5.2.0 with Suhosin-Patch
mod_python/3.3.1 Python/2.5.1 mod_ssl/2.2.0 OpenSSL/0.9.7e-p1
Apache threaded MPM No (single thread MPM)
Apache forked MPM Yes, maximum 256 processes
Apache server root /usr/local
Apache document root /deepwater/Projects/HTTPs/test/py
Apache error log /deepwater/logs/http/py.test.error.log (view last 100 lines)
Python sys.version 2.5.1 (r251:54863, Nov 16 2007, 18:10:37)
[GCC 3.4.4 [FreeBSD] 20050518]
Python sys.path
/usr/local/lib/python2.5/site-packages/setuptools-0.6c5-py2.5.egg
/usr/local/lib/python2.5/site-packages/
MySQL_python-1.2.2-py2.5-freebsd-6.1-RELEASE-i386.egg
/usr/local/lib/python25.zip
/usr/local/lib/python2.5
/usr/local/lib/python2.5/plat-freebsd6
/usr/local/lib/python2.5/lib-tk
/usr/local/lib/python2.5/lib-dynload
/usr/local/lib/python2.5/site-packages
Python interpreter name py.test.apt
mod_python.publisher available Yes
mod_python.psp available Yes
Request input headers
Key Value
Accept */*
Accept-Language en
Accept-Encoding gzip, deflate
User-Agent Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en)
AppleWebKit/523.12 (KHTML, like Gecko) Version/3.0.4 Safari/523.12
Connection keep-alive
Host py.test.apt
Request environment
... output will continue ...
