LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-12-2003, 11:50 PM   #1
jeff0628
LQ Newbie
 
Registered: Jul 2003
Location: Tulsa, OK
Distribution: SuSE 9 Professional
Posts: 13

Rep: Reputation: 0
Redhat 9 / Apache / cgi-bin ????


Hello,
I've been online for the past 12 hours (off and on) trying to find out why my redhat server is giving me this error everytime I try to execute cgi / perl scripts from the web.

Server error!
The server encountered an internal error and was unable to complete your request.
Error message:
Premature end of script headers: acepassword.cgi
If you think this is a server error, please contact the webmaster
Error 500

I have the correct permissions set for the folder and the script itself, I even tested the Hello world script from the command line which seemed ok.

I'm at a total loss?!? I have ran into a LOT of other people having the same troubles as me online so it seems that this is a common problem.

 
Old 10-13-2003, 12:15 AM   #2
a_morgan
LQ Newbie
 
Registered: Nov 2002
Location: BC, Canada
Distribution: Red Hat 9
Posts: 12

Rep: Reputation: 0
I had experienced similar errors before and my problem was because the first line in my script didn't point to the correct perl directory. (The script had the line #!/usr/local/bin/perl but for RedHat 9 I need this to be #!/usr/bin/perl)

I hope this helps.
 
Old 10-13-2003, 01:36 PM   #3
jeff0628
LQ Newbie
 
Registered: Jul 2003
Location: Tulsa, OK
Distribution: SuSE 9 Professional
Posts: 13

Original Poster
Rep: Reputation: 0
Actually this was the first thing that I checked. Currently the scripts that I'm trying to run start off with #!/usr/bin/perl

any other ideas.
 
Old 10-13-2003, 01:40 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
Try creating a test script "hello.cgi":
Code:
#!/usr/bin/perl
print "content-type:text/html\n\nHello World!";
exit;
Put it in your cgi-bin then try to access it.

If you still ahve problems then look at the server "error_log" file to see what errors it reports.

if you are unsure then post the errors from the log and a copy of your httpd.conf file.
 
Old 10-13-2003, 02:38 PM   #5
jeff0628
LQ Newbie
 
Registered: Jul 2003
Location: Tulsa, OK
Distribution: SuSE 9 Professional
Posts: 13

Original Poster
Rep: Reputation: 0
david,
ok i already tried a "hello world" script that just uses a single print command and i can execute from the cli by just perl hello.pl but anytime i try to access it from the web i get the same server 500 internal error from my original post.

since i'm a total noob how do i check the error log to find out what is really going on?

i'm at work, so as soon as i get a chance i will vsftpd into the machine and copy the httpd.conf file, otherwise i will need to wait until i get home from work.
 
Old 10-13-2003, 02:44 PM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
Take a look at:
/var/log/httpd/error_log

Post the lines that appear about the time that you tried to access the hello.cgi script.

EDIT: I'm heading out soon but will check back later or tomorrow.
 
Old 10-13-2003, 09:49 PM   #7
jeff0628
LQ Newbie
 
Registered: Jul 2003
Location: Tulsa, OK
Distribution: SuSE 9 Professional
Posts: 13

Original Poster
Rep: Reputation: 0
Ok, my error_log entry is

[Mon Oct 13 21:40:57 2003] [error] [client 192.168.254.254] Premature end of script headers: test.pl, referer: http://www.onealindustries.com/cgi-bin/test.pl

I was using your perl example from above and named it test.pl. Now I can run it from the cli just fine, but I am getting this error from my web browser.

Server error!

The server encountered an internal error and was unable to complete your request.

Error message:
Premature end of script headers: test.pl

If you think this is a server error, please contact the webmaster

Error 500

Here is my test.pl script.

#!/usr/bin/perl

print "content-type:text/html\n\nHello World!";
exit;

If you want to see my httpd.conf file I can email it to you.

thanks!!!
 
Old 10-14-2003, 12:23 PM   #8
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
Can you do 2 things:
1) Make sure the script is in your "cgi-bin" directory
2) Call the script test.cgi not test.pl in case the server is only parsing .cgi scripts

If neither of the above helps then post your httpd.conf and I'll see if I can spot any problems.
 
Old 10-14-2003, 10:11 PM   #9
jeff0628
LQ Newbie
 
Registered: Jul 2003
Location: Tulsa, OK
Distribution: SuSE 9 Professional
Posts: 13

Original Poster
Rep: Reputation: 0
ok,
my script is in /var/www/cgi-bin and i also renamed the test.pl to test.cgi and called it from my web browser and i still get the same server 500 error as before. I also called the script from the cli by

cd /var/www/cgi-bin
perl test.cgi

I do get the output this way but not from the web.

Can I email my httpd.conf file to you. I have several virtual hosts setup by calling the ip address and I don't want that posted here.

thanks
 
Old 10-15-2003, 12:57 PM   #10
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
Ok - e-mail it over, use the e-mail link below this post.
 
Old 10-15-2003, 02:12 PM   #11
mylo2003
Member
 
Registered: Jul 2003
Posts: 113

Rep: Reputation: 15
I had this problem too. I changed my httpd.conf file to this and it worked like a charm.

--The ScriptAlias piece of code has to be uncommented out and should look like this:
ScriptAlias /cgi-bin/ /var/www/cgi-bin/ ->(or relative path)

--MAKE SURE THIS LINE IS UNCOMMENTED!
AddHandler cgi-script .cgi .pl

--FINALLY, this is in the Directory part near the end of the httpd.conf file which is also important.

<Directory "/var/www/cgi-bin/">
AllowOverride None
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
 
Old 10-15-2003, 08:19 PM   #12
jeff0628
LQ Newbie
 
Registered: Jul 2003
Location: Tulsa, OK
Distribution: SuSE 9 Professional
Posts: 13

Original Poster
Rep: Reputation: 0
thanks mylo2003 I will check that in my httpd.conf file.

David, I will still email it to you just in case there is more wrong than this.

thanks guys. This is why I switched to the open source community, everyone willing to help out!
 
Old 10-16-2003, 10:56 AM   #13
Andy Ba
LQ Newbie
 
Registered: Oct 2003
Posts: 1

Rep: Reputation: 0
Quote:
Originally posted by david_ross
Try creating a test script "hello.cgi":
Code:
#!/usr/bin/perl
print "content-type:text/html\n\nHello World!";
exit;
Put it in your cgi-bin then try to access it.
Hi David,

I'm using Redhat 9.0 on a dedicated server. I was fighting the same problem not being able to run hello.pl from my web browser. What did it for me was your code above. Must be the "exit;" on the end.

Thank you.
 
Old 10-16-2003, 01:40 PM   #14
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
Good to hear. Welcome to LQ Andy Ba.

Jeff - try this example for your virtual hosts:
Code:
<VirtualHost xxx.xxx.xxx.xxx:9000>
ServerName www.domain1.com
DocumentRoot /var/www/html/domain1
<Directory "/var/www/html/domain1">
    AllowOverride AuthConfig
    Options Includes
    Order allow,deny
    Allow from all
</Directory>
<Directory "/var/www/html/domain1/cgi-bin">
    Options ExecCGI
</Directory>
</VirtualHost>
Also make sure you have this line in your config:
AddHandler cgi-script .cgi .pl

This means that you can have seperate cgi-bin directories for each host - just make sure your cgi and pl files are in there and apache has permission to execute them.
 
Old 10-16-2003, 06:05 PM   #15
jeff0628
LQ Newbie
 
Registered: Jul 2003
Location: Tulsa, OK
Distribution: SuSE 9 Professional
Posts: 13

Original Poster
Rep: Reputation: 0
David,
You are absolutely brilliant. I did get the output from the test.pl script from my web browser, FINALLY!!

Ok I have one more little snag, I take it from the VH example above that I can create a cgi-bin directory inside the /var/www/html/xxxxxx folder whenever I put the test.pl inside this folder then I get a object not found error like the path is incorrect. I did get it to work by putting the test.pl file inside /var/www/cgi-bin. Is this because of the line

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" line from my httpd.conf file.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
configuring cgi-bin in apache gtgoku Linux - General 1 01-19-2004 06:22 AM
Apache server and cgi-bin? WorldBuilder Linux - Networking 15 09-18-2003 12:13 PM
Apache cgi-bin in Mandrake 9.1 Edgemaster Linux - Newbie 1 08-14-2003 01:15 PM
no access to cgi-bin within Apache Mackeral Linux - Software 6 05-14-2002 05:15 AM
apache cgi-bin roadie Linux - General 6 06-16-2001 07:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration