Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 07-13-2005, 07:55 AM   #1
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, 08:13 AM   #2
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, 04:11 AM   #3
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

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:

print "<html><body>Hello</body></html>"

convert it to

print "\r\n";
print "<html><body>Hello</body></html>"

You can add your headers like this:

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



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 09:51 AM
CGI-script problem on Apache2 jkt2000 Linux - Networking 3 01-28-2005 04:38 AM
CGI apache2 question gothrog Linux - Software 1 09-16-2004 02:31 PM
how to install a cgi counter in apache2 hartings Programming 14 08-31-2003 10:33 AM
Apache2 CGI-Perl will not read files fefeh Linux - Software 0 06-30-2003 08:07 PM > Forums > Linux Forums > Linux - Newbie

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

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