You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Tom Cat <st...@gmail.com> on 2006/02/21 15:12:17 UTC

[users@httpd] Premature end of script headers

All of my perl scripts generate this error when I try to have Apache
serve them.  I'm on RHEL with Apache 2.0.52.

The simplest script I have is:
#!/usr/bin/perl
print "Hello";

In the error log I'm told:
[Tue Feb 21 08:57:48 2006] [error] [client 10.33.1.32] Premature end
of script headers: hello.cgi

I've tried changing LogLevel from warn to debug and still only get this message.

In httpd.conf, I load cgi_module (mod_cgi.so) at the beginning as well
as suexec_module (mod_suexec.so).

I also set the following:
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory "/var/www/cgi-bin">
    AllowOverride None
    # Options None
    Options ExecCGI
    Order allow,deny
    Allow from all
</Directory>

in /var/www, when I do ls -lh I get
drwxr-xr-x  2 root      root 4.0K Feb 21 08:53 cgi-bin

in /var/www/cgi-bin, when I do ls -l I get
-rwxr-xr-x  1 apache apache 32 Feb 20 16:01 hello.cgi

I have tried changing the owner and group of hello.cgi It was at first
both root and I changed it to apache (which is what httpd runs as).

I've tried changing the location of the cgi-bin directory.  I've tried
to change the name of the file to just hello (dropping the cgi
extension).  I've changed permissions on both the file and the cgi-bin
directory (when I do that, it will sometimes complain in suexec.log
that something is writable by others).  I've tried not loading suexec,
but that doesn't change the result.

I don't know what to do at this point.  What should I try next?

Thanks in advance,

Tom

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Premature end of script headers

Posted by Sascha Kersken <sk...@lingoworld.de>.
Hi,

Apache requires CGI scripts to generate their own Content-type headers. Try

#!/usr/bin/perl
print "Content-type: text/plain\n\nHello";

This should work.

Best
Sascha

----- Original Message ----- 
From: "Tom Cat" <st...@gmail.com>
To: <us...@httpd.apache.org>
Sent: Tuesday, February 21, 2006 3:12 PM
Subject: [users@httpd] Premature end of script headers


All of my perl scripts generate this error when I try to have Apache
serve them.  I'm on RHEL with Apache 2.0.52.

The simplest script I have is:
#!/usr/bin/perl
print "Hello";

In the error log I'm told:
[Tue Feb 21 08:57:48 2006] [error] [client 10.33.1.32] Premature end
of script headers: hello.cgi

I've tried changing LogLevel from warn to debug and still only get this 
message.

In httpd.conf, I load cgi_module (mod_cgi.so) at the beginning as well
as suexec_module (mod_suexec.so).

I also set the following:
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory "/var/www/cgi-bin">
    AllowOverride None
    # Options None
    Options ExecCGI
    Order allow,deny
    Allow from all
</Directory>

in /var/www, when I do ls -lh I get
drwxr-xr-x  2 root      root 4.0K Feb 21 08:53 cgi-bin

in /var/www/cgi-bin, when I do ls -l I get
-rwxr-xr-x  1 apache apache 32 Feb 20 16:01 hello.cgi

I have tried changing the owner and group of hello.cgi It was at first
both root and I changed it to apache (which is what httpd runs as).

I've tried changing the location of the cgi-bin directory.  I've tried
to change the name of the file to just hello (dropping the cgi
extension).  I've changed permissions on both the file and the cgi-bin
directory (when I do that, it will sometimes complain in suexec.log
that something is writable by others).  I've tried not loading suexec,
but that doesn't change the result.

I don't know what to do at this point.  What should I try next?

Thanks in advance,

Tom

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Premature end of script headers

Posted by Nick Kew <ni...@webthing.com>.
On Tuesday 21 February 2006 14:12, Tom Cat wrote:
> All of my perl scripts generate this error when I try to have Apache
> serve them.  I'm on RHEL with Apache 2.0.52.
>
> The simplest script I have is:
> #!/usr/bin/perl
> print "Hello";

That's not a CGI script.

> In the error log I'm told:
> [Tue Feb 21 08:57:48 2006] [error] [client 10.33.1.32] Premature end
> of script headers: hello.cgi

Yep.

> I don't know what to do at this point.  What should I try next?

Reading any basic introduction to CGI would be a start.

-- 
Nick Kew

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org