Forum Moderators: phranque
I`ve installed Apache 2.0.52 Server on my Red Hat 9 OS. When i try to execute the example script "printenv cgi" the server answers this:
"Internal Server Error"
The server enconuntered an internal error or misconfiguration and was unable to complete your request"
after that, i check the error log file and it says this:
File does not exist: /usr/local/apache2/htdocs/favicon.ico
(13)Permission denied: exec of '/usr/local/apache2/cgi-bin/printenv' failed
Premature end
of script headers: printenv
I don`t know how to solve this problem.
Can anyone help me out?
Thanks a lot
as you've already figured out, "Internal server error" is about the least helpful error message possible and one that plagues programmers endlessly.
The filename leads us to believe you're trying to print environment variables. If it's a perl script, there are many things that can go wrong. From most likely to maybe's,
1. The file must be executable - chmod filename 755. The directory in which it resides must also be executable.
2. The script is designed to be run from the command line and not the web, thus is missing a content-type header. Whenever you execute a cgi script, it is passed to the CGI gateway and you have to tell it what it's sending. If it tries to execute a print command anywhere without doing this first, it will 500 on you. This is fixed by placing
print "Content-type:text/html\n\n";
at the top of the script. Look the script over and see if it's got that line in it; if it does, this is not the problem.
3. The path to perl is wrong. At the top of the script,
#!/usr/bin/perl
or
#!/usr/local/bin/perl
Tells the gateway where to look for the perl interpreter. Verify this is correct.
3.a. Perl must be installed, if this is a perl script. :-)
4. There is an actual error in the script. You can determine this by moving to the script directory and typing
perl scriptname (press enter)
If you see a list of output that ends in "script aborted due to compilation errors" you'll know. If it runs fine, it's something else.
5. The file was uploaded in binary mode, it needs to be ASCII. This is due to end-of-line differences between linux and other systems.
6. The server must be configured to execute files with certain extentions. .cgi and .pl are usually configured to execute with the perl interpreter. See your config files and associated documentation.
There's more . . . but these are the top errors most encounter. Sorry if this is not a perl script! :-)