Faqts : Computers : Programming : Languages : Python

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

45 of 58 people (78%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

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

Oct 1st, 2009 04:16
jsieoa gide, Scott Mandarich, Joe Bloggs, johnny deep, john Cena, raj sandia, games games, Vivek Kumar, Gerhard Haering, http://www.sidekick2.info/


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
------------------------------------------------------------------------
http://bozicnipokloni.blogspot.com/
http://karacsonyiajandekok1.blogspot.com/
http://kerstcadeaus.blogspot.com/
http://presentesdenatal1.blogspot.com/
http://kysymyksenvastaukset.blogspot.com/
http://festivalfestiviteiten.blogspot.com/
http://svaretblog.blogspot.com/
http://festivalbl.blogspot.com/
http://regalidinatale1.blogspot.com/
http://weihnachtsgeschenke1.blogspot.com/
http://cadeauxdenoel1.blogspot.com/
http://christmasgifts215.blogspot.com/
http://festivaloslavy.blogspot.com/
http://fragebeantwortet.blogspot.com/
http://festivblogi.blogspot.com/
http://cadouridecraciun1.blogspot.com/
http://julegaver1.blogspot.com/
http://christmasgifts211.blogspot.com/
------------------------------------------------------------------------
http://www.abovethelaw.info/