Internal Server Error

I tried to install a Perl script and got Internal Server Error. What can I do, what did I do wrong?

This is a frequent question and there is no simple answer. There can be several reasons why this error happens.

First of all check that the Perl script is syntactically correct. To do this try to start the program from the command line using the command:

perl -c test.cgi

Check that you have uploaded the code to the server using ASCII mode. Upload the code again using ASCII mode even if you are sure, you did upload it using ASCII mode. To be 100% sure that the file was uploaded ASCII mode, download the file into a separate directory in binary mode and open it using Notepad. You have to see small rectangles instead of the line breaks and all the code on a single line.

If there is no error in the program, you may want to look into the tail of the error log file. This is on the server usually located in /var/log/apache/error.log. However it may be located in different directory or even named differently on your server. The Apache server writes a bit more information on the type of the error into the error log, that may help you to diagnose the reason.

Make sure that the program writes out the correct header information. Thus the program has to have some print statements that print out lines like

Status: 200 OK\nContent-Type: text/html\n\n

Note that there should be an extra \n to close the header.

If you can not look into the error log file then you can alter your code so that it starts like:

#! /usr/bin/perl
print "Status: 200 OK\nContent-Type: text/html\n\n";

which will print the header even before the program is loaded. This can also be done if you can not run the program from the command line.

As a last resort you can press the Refresh or Reload button on your browser. This may solve the problem if the web server generates the error due to heavy load. This is not likely though in most cases.

This page was generated June 28, 2002 13:16:09