Uploading Perl CGI scripts

Perl CGI is fully supported on all Digital Crocus accounts within our secured virtual private server environment. In order to set up CGI scripts in the most secure way please follow these instructions.

  • CGI scripts do not need to be placed in a cgi-bin folder.

Many installation guides will say "upload this program into your cgi-bin folder". At Digital Crocus we do not restrict CGI to one folder, you may upload CGI scripts into any folder you like.

  • You must set the execute bit on CGI scripts (chmod +x), you should consult your FTP client documentation to learn how to do this.
  • Perl is located at /usr/bin/perl

This means the first line of your Perl scripts should be #!/usr/bin/perl. If your scripts are configured to use /usr/local/bin/perl, this will also work.

  • Sendmail is located at /usr/sbin/sendmail
  • CGI scripts run 'as you'.

When a CGI script executes, it has the same permissions you do when you login to the server. This means if you need to make a file or directory writable from your script you do not need to make it world writable (chmod 777), in fact it is a very good idea not to. If the installation instructions for your script tell you to make something world writable (chmod 777 or 666), you should omit this step.

  • Database connections are to 'localhost'

If your script needs to connect to MySQL, the server hostname you should use is 'localhost', this will usually be the default. You should login to MySQL as your main account username and with the password you defined via the databases section of the control panel. You will need to create at least one database (via the control panel) before you are able to login to MySQL.

  • Your error and suexec logs are your best debugging tool

Full server error and suexec logs are available to aid in resolving problems with your CGI scripts. If you are experiencing an unexplained error 500 (Internal server error) or are receiving blank pages from your CGI scripts, your log files should be your first port of call for problem solving. The error log will display many general script errors, the suexec log will display permissions problems that are preventing your scripts from executing. For any CGI problem, please consult both logs before contacting support.


This entry was posted in Dynamic Content (PHP and CGI). Bookmark the permalink.