Why do I get 500 Internal Server Error when I try to run my CGI scripts?
500 Internal Server errors occur when the webserver is able to access the file, but it cannot execute it, or it does not understand the output.
One of the most common reasons for this error is incorrect file permissions. Cgi-bin scripts and executables must have the proper permissions or an internal server error will occur. The directory (and all the CGI scripts within it) must NOT be world writable. This is the most common error. See How do I set permissions? for information to set the correct file permissions.
This error can also occur if you have uploaded the CGI script as binary instead of ASCII. Most FTP clients will give you the option to upload in either binary or ASCII mode. Consult your FTP client's Help files if for more information on how to change the upload method.
Some editors add extraneous characters that will cause a problem with running the script. Don't use Word, WordPerfect, or any other 'word processing' program. Use a basic text editor like Notepad, WordPad, Pico, SimpleText or a similar program. Open the script in a text editor and try re-saving it to your hard drive before FTPing it.
All Perl scripts must start with an identifier, called the "shebang", which tells the server the path to find the Perl interpreter so that it can run the program. This is usually the first line of the script and should look like #!/usr/local/bin/perl. Perl can be found on most Expedient servers in /usr/local/bin/perl. If you have shell access to your webspace, you can check the location of perl with the command: which perl
Make sure ACTION="" of script on the web page is pointing to the correct CGI program and has the correct path.
Check the syntax of the script. Every statement in a Perl script must end with a semicolon (;) except conditionals and subroutines; these are enclosed in brackets. Perl variables must start with a $, % or @; be sure a symbol was not omitted from a variable name. Check to be sure that quotes and apostrophes are present on each end of strings as appropriate. Be sure that escape characters - in Perl, the backslash (\) are included in a quoted string where needed with a quotation mark or apostrophe if needed.
If everything above checks out okay, chances are there may be an error within the script itself. If you downloaded the script from an online archive, double check any changes you have made. Most downloaded scripts have a readme file or comments added to the script to help you configure it properly.
Top