[Tutor] Python in Apache?

Israel Evans israel@lith.com
Thu, 24 Jan 2002 12:59:24 -0800


	Has anyone here ever attempted to get Python cgi 
files to run in an apache server?  I seem to be having 
trouble though everything looks right and I don't know 
whether it's python or apache that's causing me problems.

The following is a bit long but I think it's thorough
These are the things I have set up.



This is my script alias in httpd.config which I think is 
set up correctly.  The path I've set up is correct, but 
I'm new to the options so I may be off.
############################################

ScriptAlias /cgi-bin/ "C:/Weblish/cgi-bin/"

    <Directory "C:/Weblish/cgi-bin/">
        AllowOverride None
        Options +ExecCGI
        Order allow,deny
        Allow from all
    </Directory>

############################################





I don't have Perl on my machine, but I do have Python, 
which I like much better so I'm using that as the language 
for my cgi programs.  My super simple introductory cgi is 
as follows.  I've got Python in my Path and using this 
Shebang line I'm able to run python scripts just fine by 
clicking on them.
######################################

#! % python

header = "Content-type: text/html\n\n"
content = "Hello, Baby."

print header, content

######################################




I access this cgi file by entering 
"http://localhost/cgi-bin/test.cgi"  
into my browser after having made sure that the Server 
is running.

I get the following error message:
####################################

Internal Server Error

The server encountered an internal error or 
misconfiguration and was unable to complete your request.

Please contact the server administrator, Israel@lith.com 
and inform them of the time the error occurred, and anything 
you might have done that may have caused the error.

More information about this error may be available in the 
server error log.

  _____  

Apache/1.3.20 Server at ISREAL.lith.com Port 80

##########################################





And when I look into the Error logs I find these tidbitsof information:
#############################################

[Thu Jan 24 08:08:42 2002] [error] [client 127.0.0.1] 
attempt to invoke directory as script: c:/weblish/cgi-bin
[Thu Jan 24 08:11:28 2002] [error] [client 127.0.0.1] 
couldn't spawn child process: c:/weblish/cgi-bin/test.cgi

#############################################