[mod_python] I can't get apache to handle a .py file

Rick Bunke rbunke at helios.acomp.usf.edu
Thu May 10 20:38:40 EST 2001


Hello,

I'm stuck.  I've read the FAQ.  I've read mod_python Manuel up to 2.4
testing your new installation.  I've followed the directions there for
mptest.py but all apache will do for me is serve up the text file
mptest.py.  It wont hand it off to mod_python.  I compiled the mod into
apache as static not DSO. 

I'll be glad to send the bulk of my config file if requested to do so but
here is what I think is the important stuff.

httpd.conf
#------ 
LogLevel debug

DocumentRoot "/home/myhome/Text/Web"

#I was just trying to turn every thing on here while I was troubleshouting
#this problem...
<Directory "/">
        Options All +MultiViews
</Directory>

# Python stuff according to mod_python manuel
<Directory "/home/myhome/Texts/Web/pytest">
        AddHandler python-program .py
        PythonHandler mptest
        PythonDebug On
</Directory>
#--------

the config file is basically identical to apache default config
file with the specific site info changed.

[black_box]cat mptest.py
from mod_python import apache
    
def handler(req):
        req.send_http_header()
        req.write("Hello World!")
        return apache.OK

[black_box]ls -l mptest.py
-rwxr-xr-x    1 rick     rick          123 May 10 19:35 mptest.py*

I wasn't sure if mptest.py was suppose to be excutable or not so I it
made it excutable just in case.

when I put a "#!/usr/local/python" in at the top and run it stand alone, 
it doesn't like the "import _apache" line which doesn't really surprise me
sense I don't think your suppose to run it like that :)  I was just trying
to figure what was wrong sense I get no errors in my error.log 

When I type "http://myip/pytest/mptest.py" in web my browser, it displays 
the text file:

from mod_python import apache
    
def handler(req):
	req.send_http_header()
	req.write("Hello World!")
	return apache.OK


Also, when I compiled apache, it failed in the mod_python directory saying
some functions (openpty and forkpty) were "undefined references" so I had
to add "-lutil" to the 
"LIBS="$LIBS -lm /usr/local/src/Python-2.1c2/libpython2.1.a"" 
line in the libpython.module config file, rerun configure, and then it
would compile ok.  possable bug in the configure scripts, or my setup, I
don't know which.

I run Linux 2.4.4
Python 2.1c2 
Apache 1.3.19
Mod_Python 2.7.2

Please help me :)

Thanks
Rick

we enjoy great advantages from the inventions of others, we should be 
glad of an opportunity to serve others by any invention of ours; and 
this we should do freely and generously.
		- Ben Franklin (declining to take out a patent on the
				Franklin Stove)

Whenever there is a conflict between human rights and property rights, 
human rights must prevail.
	           - Abraham Lincoln
	
Information is the currency of democracy.
		   - Thomas Jefferson




More information about the Mod_python mailing list