using python as cgi on apache unix

Gerhard Häring gerhard.haering at
Tue Sep 17 02:46:48 EDT 2002

* josh_py at <josh_py at> [2002-09-16 22:48 -0700]:
> All,
> I have developed a python solution to run and connect to a mysql database.
> I did all my development under windows apache 1.3.26 and python 2.2.1.  I
> know want to move this to my unix server.  Unfortunately, no matter what I
> do I can not get apache on my linux box to execute any python scripts.  I
> get the following errors in apache:
> Premature end of script headers: /var/www/html/cgi-bin/
> I have all the settings in apache I believe to be correct.  It complains
> that the file is not executible if that is not set.  Other CGI works fine.
> looks like:
> #!/usr/bin/python2
> print "\n\n"
> print "Content-Type: text/html\n\n"
> print "hello"

The first print "\n\n" is an error. It was simply luck that this was
running anywhere else as expected. Just delete this line and your hello
world cgi script should run fine.

Also, to test wether Python CGI scripts work, you can always simply use:

#! [path to python ...]
import cgi

-- Gerhard

More information about the Python-list mailing list