Script Permissions

It's not uncommon to run into problems when setting up CGI scripts on your web site. One of the most common errors is the "403 Forbidden Error". A 403 error occurs when a file doesn't have sufficient permission to run. Permission can be adjusted via SSH using the "chmod" command, although many find it easier to change permissions using the "chmod" feature in an FTP program. To set a script as executable, you want to change it's permission to 755. In SSH, this can be accomplished by typing:

 

chmod 755 scriptname.pl

(where scriptname.pl is the name of the script you wish to change).

 

CGIs must be set with executable file permissions or requests for the script from the web server will result in an internal server error.

Scripts that need to be executable should have their permission set with "chmod 755". This sets the file's permissions so that the file's owner may read, write, and execute the file, and anyone else can only read and execute it.

 

Internal Server Error

The "500 Internal Server Error" is a common error that occurs when installing new scripts. In an attempt to troubleshoot this error you should attempt the follow:

  1. Make sure that the script was uploaded to the server as ASCII and not as BINARY. If the file is uploaded as BINARY it will become corrupted in transfer and the 500 error will occur. All FTP programs have a setting that can be toggled for ASCII, BINARY and AUTO. If you are in doubt as to what method was used to upload your file, it's best to set it manually to ASCII and upload your file again.
  2. Make sure the first line of your script is the path to Perl, and that it is correct. In the vast majority of cases, it should look like:

    #!/usr/bin/perl