Forum Moderators: coopster & phranque

Message Too Old, No Replies

500 - Internal Server Er - Premature end of script headers

500 - Internal Serv Er - Premature end of script head. apache 1.3.29OpenBSD

         

Roman Harcek

7:32 pm on Aug 9, 2006 (gmt 0)

10+ Year Member



Hi,
I am having big troubles making the CGI script working on my apache
v. 1.3.29 under Open BSD unix 3.7. I am logging using the root account. The webpage itself (html) loads default - from the var/www/htdocs directory and it works fine.
But when I try to call a CGI script for example: lynx 127.0.0.1/cgi-bin/test3.cgi
I am still getting the 500 - internal server error message.
When I watch error logs file I found there just like:
[Sun Aug 6 10:49:28 2006] [error] [client 127.0.0.1] Premature end of script headers: /cgi-bin/test3.cgi
[Sun Aug 6 10:49:47 2006] [error] [client 127.0.0.1] Premature end of script headers: /cgi-bin/test3.cgi
messages.
The script I am trying to make running is very simle:
it is not PERL but I also tried some in PERL and also works not. This my script is in simple c, here it is:
for example test3.c file:
main ()
{
printf ("Content-type: text/plain\n\n");
printf ("hello, world\n");
return 0;
}
thats all. I compile it using c test3.c -o test3.cgi
I change the permissions using:
chmod a+x test3.cgi
When I run it from system shell it works well:
Here is the OUTPUT:
Content-type: text/plain
blank line
hello, world
Then I run httpd, and then run for example lynx 127.0.0.1/cgi-bin/test3.cgi I am still getting error message.

I made following changes in my httpd.conf:
Options All
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
<Directory "/var/www/cgi-bin">
AllowOverride None
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
AddHandler cgi-script .cgi .pl

thats all I think.
I was also trying to run some other scripts, for examle, there was 2 default PERL script in the cgi-bin
directory: test-cgi and printenv, I changed their using chmod +x and renamed to .pl , but when I try to
run then , I am still getting the same error message 500-int. serv. error and Premature end of script headers
in the log file .
Where can be the problem? Have I to change something? Made I some mistakes?
Please help
THX a lot

MichaelBluejay

7:57 am on Aug 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You probably need to set the permissions of the file with the chmod command from the command line.

perl_diver

6:30 pm on Aug 12, 2006 (gmt 0)

10+ Year Member



it's a c script? Then you probably need to add .c to the AddHandler list too:

AddHandler cgi-script .cgi .pl .c

FLtab

8:19 pm on Aug 15, 2006 (gmt 0)

10+ Year Member



Check the permissions on each directory above your script as well as the script itself. Make sure that the user your httpd runs as has at least "x" access to the directories and the program/script itself.