Home     My Faqts     Contributors     About     Help    

faqts : Computers : Programming : Languages : Python

FAQTs repaired & updated!
Thanks for your patience...
Entry Add Entry Alert - Edit this Entry

Did You Find This Entry Useful?

37 of 44 people (84%) answered Yes
Recently 7 of 10 people (70%) answered Yes

How do I set up up Apache to serve Python CGI-scripts on Windows?

Jan 17th, 2003 15:46

Vivek Kumar, Gerhard Haering


In the Apache configuration file httpd.conf, add the following line at 
the end of the file:
ScriptInterpreterSource Registry
Then, give your Python CGI-scripts the extension .py and put them in 
the 
cgi-bin directory.
A minimal Python CGI script that will work on Windows *and* Unix will 
then look like this (the first line beginning with #! assures that it 
will run on Unix, too):
#!/usr/bin/env python
# Filename: test.py
print 'Content-type: text/plain\n'
print 'Python CGIs work!'
===========================================================
or alternatively if you want to simply run ur apache server on windows 
only, then u can also do the following
in ur httpd.conf (in c:\program files\apache group\apache\) file set 
the document root to the path where u store ur html files
like
DocumentRoot "c:/python22/web/html"
also change the index file name according to ur site index page
<IfModule mod_dir.c>
    DirectoryIndex mywebindex.htm
</IfModule>
also change ur script alias directory
ScriptAlias /cgi-bin/ "c:/python22/web/cgi-bin"
In every python cgi file u shoyld add the path of the python executable 
as mentioned in the above message
like for windows u can have
#!c:\python22\python
and in linux u can have
#!/usr/bin/python
and in cygwin
#!/bin/python



© 1999-2004 Synop Pty Ltd