Help! My CGI Stopped Working!

A recent change in the CSAIL Web servers has caused some CGI scripts to stop working. We have identified two common causes for this problem:

500 Internal Server Error

This often (but not always) means that your script is invoking its interpreter by an incorrect path. If you check /var/log/apache2/error.log and see a message about "No such file or directory", that is almost certainly your problem. This is a particular issue for Perl scripts. The Perl interpreter used to be located in /usr/local/bin/perl, but nearly all distributions (including Debian) have put it in /usr/bin/perl for quite some time. If you change the first line ("shebang") of your script to refer to the interpreter by the correct path, or to use the /usr/bin/env perl hack, it should work again.

(If, by the way, you find that there is some module or package that you need which is not currently available on the Web servers, please let us know.)

Server sends text of script rather than executing it

Previously, files ending in .pl and .py were assumed to be CGI scripts; now they are not. Files ending in .cgi were, and will continue to be, recognized. There are two ways to fix this:
  1. Rename the script. Note that doing this will break existing links and bookmarks, which is widely considered to be a Bad Thing. (Our servers have MultiViews turned on globally, so you should be able to leave the ending out of links, so that you don't expose implementation details to all and sundry.)
  2. Add AddHandler cgi-script .pl to your .htaccess file. This tells the server to interpret .pl in the way it used to. (Likewise for .py.)

-- GarrettWollman - 15 Aug 2007