Forum Moderators: phranque

Message Too Old, No Replies

Seems to be an apache conf problem

         

rizwan65

7:10 pm on May 4, 2005 (gmt 0)

10+ Year Member



Hello,
I've been trying to run a simple cgi script but recieving an error:
Premature end of script headers: test.cgi

The code is as under:

#!/usr/bin/perl
use strict;
use CGI::Carp qw(fatalsToBrowser);

print "Content-type: text/html\n\n";
print "<html><head><title>This is a URL test</title></head>";
print "<body>This is a URL test</body></html>";

exit 1;

I tried the this cgi on my server's cgi-bin and it worked but if I use it in the cgi-bin of Virtual site it didn't works

e.g.
1. [my.ip.address...] (Works)

2. [mysites.com...] (Same error Premature end of script headers: test.cgi)

I think it is some sort of Apache Configuration issue but I don't know how to solve it

Any suggestions

sitz

2:26 am on May 5, 2005 (gmt 0)

10+ Year Member



is the virtual site being served by the same apache instance as 'your server'? Can you post the relevant sections of your httpd.conf (anything that references 'cgi-bin' or 'Script' or '.cgi')?

rizwan65

5:29 pm on May 5, 2005 (gmt 0)

10+ Year Member



Yes the virtual site is also being served by same server

Below is the httpd.conf section of one of the virtual sites

Please note that
1. cgis are not running on any of the virtual sites
2. The hashed code that you see below is because I tried this with and without hashing this code.

<VirtualHost my.ip.address:80>
SuexecUserGroup "#501" "#501"
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot /home/mysite/public_html
ErrorLog /home/mysite/logs/error_log
CustomLog /home/mysite/logs/access_log common
ScriptAlias /cgi-bin/ "/home/mysite/cgi-bin/"
<Directory /home/mysite/public_html>
Options Indexes IncludesNOEXEC FollowSymLinks
allow from all
</Directory>
#<Directory "/home/mysite/cgi-bin/">
#SetHandler cgi-script
#Options ExecCGI
#AllowOverride None
# Options None
# Order allow,deny
# Allow from all
#</Directory>
</VirtualHost>

sitz

6:36 pm on May 5, 2005 (gmt 0)

10+ Year Member



Ah, suexec. Check your error log for interesting errors; also check your suexec log for errors; if suexec's causing the issue (and that's the error you'd get if it is, although that error can appear for other reasons), a fairly detailed explanation as to why should be there.

rizwan65

6:57 pm on May 5, 2005 (gmt 0)

10+ Year Member



suexec log is as under

[2005-05-06 23:53:23]: uid: (501/mysite) gid: (501/501) cmd: test.cgi
[2005-05-06 23:53:23]: command not in docroot (/home/mysite/cgi-bin/test.cgi)

sitz

10:43 pm on May 5, 2005 (gmt 0)

10+ Year Member



Looks like your script isn't in the proper directory; check out [httpd.apache.org ] for the definition of the compile-time options for suexec.