I installed the httpd.conf file. Didnt make any changes to it. I saw where you had indicated the origional content. I changed my servername to localhost. and changed all ownerships to root. Each time trying script before making any changes. I then went so far as to delete everthing except #! usr/bin/perl still errored. Now I checked the apache error logs and I get the same message premature end of script header, I also get an error, "cannot open perl script "!" No such file or directory.

I just found this:

Generally, when you get this type of error from a cgi it means
you did not generate the header properly.

If you did not modified the script, I don't see how this could
have happened; if you did, make sure the first "print" line
does a:

print "Content-type: text/html\n\n";

URL: http://www.opensrs.org/archives/resellers-list/0002/0054.html

OK, try this as well:

from a console on your *nix box, navigate to your cgi-bin directory, and manually run the .cgi script.

This is the stdout when I just did it:

kevin@mars$ cd /usr/local/www/cgi-bin
 kevin@mars$ ./hello.cgi
 Content-type: text/plain
 Hello World!

when I run using ./hello.cgi- it says no such file or directory...if I run using " perl hello.cgi " - I get the same out put as you.

OK, in your httpd.conf, look for:

AddHandler cgi-script .cgi

and add .pl:

AddHandler cgi-script .cgi .pl

Restart Apache by doing (as root):

apachectl restart

then try running the commandline again. If you got the same stdout that I posted earlier, you should be able to run the .cgi in the browser.

ok i did that but still get error...however I noticed that if I edit the line:

#AddHandler cgi-script .cgi .pl

to reflect

AddHandler cgi-script .cgi .pl

then restart apache and try the script....WHen I go back to the conf file
the # has been added back into the AddHandler......

Did you edit httpd.conf as root? (I know, stupid question, but I just have to ask :)

:)...Not stupid question..if It is stupid thing to do , You can count on me to do it..

I am using gedit from /etc/httpd/conf/ --- gedit httpd.conf

I checked it afterwards to make sure the changes to effect...

Let me have a look at my Apache Cookbook to see if it has anything in there regarding this issue. I completely forgot I had it, or I would've checked it before :P

I found the problem...I searched around and somewhere I found that someone was having the same problem, and it was coming from the fact that when he uploaded it using FTP. That it was not being uploaded as ascii.. even though he had selected that transfer mode..so i emailed the file directly to the server and then just saved to the file and presto whamo..

Now on to the next problem...any idea why that would happen? :)

Thank you so much for all your help...You really went beyond the call and I appreciate it and this forum...

I am sure I will talk to you later..I have plenty of issues a head of me..



No problem. I'm glad you finally got it working :) If you're going to be creating a lot of test .cgi files, it might be a good idea to actually create them on your Linux box, as opposed to transferring them later. It prevents a bunch of problems, and besides, it makes you practice you vi/emacs/pico skills while doing it :)

I have the same problem, I'm running Elive linux, (based on Debian), and I've installed Apache 2.

I keep getting 500 internal server error whenever I try running a script.

the path to perl is correct ( /usr/bin/perl )
file permissions are all ok
the scripts themselves are ok because they run on my windows machine and on a unix server with no problems.

is this a common problem on linux? is there something I don't know about?

yours hair-tearing-out-ing-ly,


What does the Apache error log show?
Did you view the file on the server to make sure there's no "^M" characters at the end of each line?
Did you try one of my earlier suggestions to make sure the server is reading the file as a text file?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.