Common issues with PHP in CGI-Mode

PHP is only accessible to faculty, staff and students with a cgi-bin setup. This is due to our multi-user environment for security purposes.

Internal Server Error

This is by far the biggest issue and hardest to debug. There are several reasons this may come up, which include:

Wrong Path

Always use the following path at the very top of your PHP script so it looks like:


Incorrect Permissions

A cgi script will not run if the file is world writable, but have to be world readable/executable (so that the webserver has access). Files are run as the owner of the file. Files should be set with the correct permissions:

//A group file (in a cgi-groups director)
#chmod 775 filename
//File permissions should look like the following:
-rwxrwxr-x 1        username group        35 Oct 23 10:50 test.php

//A personal file (in your home directory cgi-bin)
#chmod 755 filename
//File permissions should look like the following:
-rwxr-xr-x 1         username group         35 Oct 23 10:50 test.cgi

Incorrect Line Endings

Line endings must be in UNIX format. If you try and use MS Wordpad, or a similar MS editor, it will break the script. To tell if your script has incorrect line endings, open the file with VI at an UNIX command line. If you see ^Ms you must resave the file using another editor. Dreamweaver is one example of an editor that supports UNIX line endings.