LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-13-2005, 08:55 AM   #1
karthik85nitt
LQ Newbie
 
Registered: Jun 2005
Posts: 2

Rep: Reputation: 0
Red face CGI With Apache2


I'm having problems with executing cgi-scripts with Apache2.I tried the sample perl "hello world" script(hello.cgi).The script works fine when executed via the command line,but when requested via the browser,it says"500 Internal server error".I gave the command chmod a+x ./hello.cgi and added "Allow OverrideOptions " to the httpd.conf file and "Options +ExecCGI " to the .htaccess file,but still mozilla still says "500 Internal server error".The error_log file says "Premature end of script headers".There is no syntax error in the program as i copied the source from apache manual.Any help would be gladly welcome.
 
Old 07-13-2005, 09:13 AM   #2
Xyem
Member
 
Registered: Apr 2005
Distribution: Fedora Core 4
Posts: 100

Rep: Reputation: 15
Another possibility is the shebang line (path to interpreter) is wrong.
 
Old 07-15-2005, 05:11 AM   #3
juanjobnt
LQ Newbie
 
Registered: Jul 2005
Posts: 1

Rep: Reputation: 0
I had the same problem as you recently.

The cgi should generate the response headers, but not the status line.
Note that I am not an expert in cgis, but that's what happened to me with a simple hello.pl

If you don't want to include headers, just include an empty line at the beginning of the output of the cgi. That is, if you script is something like:

#!/bin/perl
print "<html><body>Hello</body></html>"

convert it to

#!/bin/perl
print "\r\n";
print "<html><body>Hello</body></html>"

You can add your headers like this:

#!/bin/perl
print "Content-Type:text/html\r\n"
print "\r\n";
print "<html><body>Hello</body></html>"

HTH
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache2 php5 (cgi-fcgi). hgb Linux - Software 2 11-16-2005 10:51 AM
CGI-script problem on Apache2 jkt2000 Linux - Networking 3 01-28-2005 05:38 AM
CGI apache2 question gothrog Linux - Software 1 09-16-2004 03:31 PM
how to install a cgi counter in apache2 hartings Programming 14 08-31-2003 11:33 AM
Apache2 CGI-Perl will not read files fefeh Linux - Software 0 06-30-2003 09:07 PM


All times are GMT -5. The time now is 12:41 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