Re: Cgi scripts in apache not working



David a écrit :
I've looked all over the place for an answer, and the only one I can
find doesn't mean anything to me. The end of line issue with writting
it in Windows and then uploading it doesn't help me since I'm doing
this all from Linux. I've been trying to get python cgi scripts to
work, and I always end up with a "Premature end of script headers" in
the error log.

The scripts are executable by all

Is it executable by yourself ?

and my httpd.conf seems fine. I also
tested it out in /var/www/cgi-bin/ and there it seems to work fine.

test2.py:

#!/usr/bin/python
print "Content-type: text/html\n\n"
print """<html>
<head></head>
<body>
<h1>Hello World</h1>
</body>
</html>"""

httpd.conf:

<Directory "/home/*/public_html/cgi/"> << Tried it with "" and no ""

shoud be without "" AFAIK (well, it's without on all our servers !-)

Options ExecCGI << Tried with "Options +ExecCGI"

        AddHandler cgi-script .cgi .py << Tried with "SetHandler
cgi-script", but still no go

<ot> SetHandler tells apache to treat everything as a cgi , whatever the .xxx </ot>


I've tried your script (renamed py.cgi, because .py is not in my default apache conf and I wanted to try it out of the box), with the following conf for userdirs:


<Directory /home/*/public_html/cgi-bin>
     Options +ExecCGI -Includes -Indexes
     SetHandler cgi-script
</Directory>

runs fine.

I've then added a .htaccess in my ~/public_html:
Options +ExecCGI
AddHandler cgi-script .cgi

And mv'd py.cgi from ~/public_html/cgi-bin to ~/public_html.

runs fine.


error_log:

[Thu Jul 28 11:44:53 2005] [error] [client xxx.xxx.xxx.xxx] Premature
end of script headers: test2.py


What are the previous and next lines ? I've found such a line in my error_log, due to me forgetting to make the script executable, and there was a


[Fri Jul 29 01:14:33 2005] [error] [client 127.0.0.1] (13)Permission denied: exec of '/home/bruno/public_html/cgi-bin/py.cgi' failed

before.

Then I tried chmod u-x py.cgi, and got the same error message as you did, but this time with no "Permission denied" before.

Aayway, I think your problem is with permissions and/or your apache conf, so you may find more useful help on an apache ng.

My 2 cents
.



Relevant Pages

  • Re: Php file expired
    ... with os time settings it starts to work again. ... The apache conf of the script uses mod_expire, may the error be related to ... If not, do you use Zend, google for "Zen expiration" try to reinstall ...
    (comp.lang.php)
  • Re: apache2 mod_perl sarge not working
    ... > the script is functioning. ... but I believe ExecCGI is mutually exclusive to ... To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org ...
    (Debian-User)
  • cgi - perl-w OK but per not
    ... When running a script (all.pl and .cgi set to ExecCGI in apache.conf) ... I get a warning but it runs: ...
    (perl.beginners)