Help - Search - Members - Calendar
Full Version: Can't get cgi to work... current conf included below
The Planet Forums > System Administration > Web Hosting
spiritguardian
I'm on RHEL 3. I have created an addon domain and wish to run cgi scripts there, but I'm running into a dead end. Here's my basic test script:

File: index.cgi
################
#!/usr/bin/perl

print "hi.nrn";

exit;

-----------------------------------------------

I run this file from the command line and I get "hi." in text.

It's located here:

/home/PrimaryUser/public_html/basseyworld/cgi-bin/

Which can be found at http://www.basseyworld.com/cgi-bin/index.cgi

The error in the log looks like this:

Premature end of script headers: /home/PrimaryUser/public_html/basseyworld/cgi-bin/index.cgi

Here's the http.conf entry for the addondomainuser.

ScriptAlias /cgi-bin/ /home/PrimaryUser/public_html/basseyworld/cgi-bin/




What have I gotten wrong?
clearsignal
make sure your first line of the script is: #!/usr/bin/perl
Make sure the file is executable ie: chmod 755 whatever.cgi
Make sure you are uploading in ASCII format not binary.
You may need a content-type line if you are trying to output this to the web:

CODE
#!/usr/bin/perl



print "Content-type: text/htmlnn";

print "Hello world!";

Hope this helps
spiritguardian
Ok, I used the exact code you referenced.

CODE
#!/usr/bin/perl



print "Content-type: text/htmlnn";

print "Hello world!";



I am using emacs to create and edit these files.

index .cgi is owned by a non-root user. It's chmod to 755.

I still get

Internal Server Error caused by "Premature end of script headers"



Like I said, perl is running fine. I can execute this on the command line - if that's working.... I think it's an Apache and/or a permissions issue.
chirpy
You definitely need the content-type line that clearsignal gave you.

I presume this is on a cPanel server?

Make sure that the following directory is also CHMOD 755:

/home/PrimaryUser/public_html/basseyworld/cgi-bin

If you still have problems, if you have suexec enabled, check the log in:
/etc/httpd/logs/suexec_log
clearsignal
ya, you stumped me.
You could try moving the file to your main web root and chmodding and running it from there. Perhaps there's a prob with the script alias...that's all i can think of.

Does any perl/cgi work anywhere else on your server/sites - are you running suexec.
spiritguardian
chirpy, thanks!

/etc/httpd/logs/suexec_log

had the key. I've never heard of this log before ( I come from a FreeBSD background) but it had this in it:

CODE
error: directory is writable by others


Eureka!
chirpy
Excellent! icon_biggrin.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.