using python as cgi on apache unix

josh_py at sautez.com josh_py at sautez.com
Tue Sep 17 03:35:23 EDT 2002


"Gerhard Häring" <gerhard.haering at gmx.de> wrote in message
news:mailman.1032245299.5563.python-list at python.org...
> * josh_py at sautez.com <josh_py at sautez.com> [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/test.py
> >
> > 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.
> >
> > test.py 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
> cgi.test()
>
> -- Gerhard
>

Gerhard,

Thanks for the test scipt.  Unfortunely that runs fine at a command prompt
but same error results under apache.

Josh





More information about the Python-list mailing list