Error 500 “Internal Server Error” occurs when the script that you placed on the server cannot be run, when there are errors in the script, or when an incorrect instruction is placed in the .htaccess file. This list of reasons for the 500 error is not exhaustive; there are many more reasons why the 500 error can occur. However, the three cases mentioned are the most common.

Let's first consider the case where you placed an incorrect instruction in the .htaccess file. If you made a mistake in spelling the name of the required directive or its parameters, you will find something like the following error in the error.log file:

[Wed Apr 14 17:01:38 2004] [alert] [client 217.16.16.16]
/home/uXXXXX/aaa.ru/www/.htaccess:Invalid command 'DrectoryIndex',
perhaps mis-spelled or defined bya module not included in the server
configuration

The web server will tell you which specific directive it considered to be erroneous and will need to be corrected. In this case, the web server reported that it did not know the DrectoryIndex directive. And indeed, there is no DrectoryIndex directive, there is DirectoryIndex. There is a typo.

If error 500 occurs when accessing a Perl script located in the cgi-bin directory, you need to check the access rights to this script. The permissions should be 755 (rwxrx-rx). If this is not the case, you need to change the rights to 755 using the chmod 755 script.pl command in the unix shell or use FTP for this. It should be noted separately that permissions for scripts must be set strictly to 755.

Please check whether you used the correct FTP file transfer mode when uploading the script to our server. All scripts, as well as any other text files, must be transferred via FTP in text (ASCII) mode. If the binary file transfer mode was used, the scripts will probably not work.

If, after checking the correctness of the set rights to the script file, the error does not disappear, you need to examine the latest entries in the error.log file - the web server places all error messages in it. So you will find a line like

[Fri Apr  9 15:05:31 2004] [error][client 217.16.16.16] Premature end of
script headers: /home/uXXXX/aaa.ru/cgi-bin/script.pl

The first thing you need to do when you receive such an error is to check whether the script issues HTTP headers correctly. Each script must first print a line indicating the corresponding Content-type and only then directly what the user will see (for example, HTML code). An example line for displaying the title of a regular HTML document:

print "Content-type: text/html; charset=windows-1251\n\n";

If, after issuing the correct headers, the 500 error does not disappear, you need to check the correct operation of the script as a whole. To do this, you need to gain access to the unix shell and then run the syntax checking command:

> perl -cw script.pl
script.pl syntax OK

If the script is written with errors, they need to be corrected using the appropriate diagnostics, and the script syntax must be checked again.

Hjalp dette svar dig? 30 Kunder som kunne bruge dette svar (90 Stem)