[OnCloud] Perl

Details of Perl Setup

  • The Perl "path" is the same as is visible via FTP. For example, the path to your tmp directory is /tmp, and the path to your document root is /docs
  • Socket functions are disabled
  • All Perl scripts must be in the /cgi-bin directory to execute. They must be set with the execute bit on (chmod 755).
  • Always upload Perl and HTML in ASCII mode in your FTP Client. Perl scripts uploaded in binary mode will result in an 'Internal Server Error'
  • To send email from your Perl scripts, you should use SMTP Auth from mail.domain.com, where domain.com is your actual domain name. You will need to properly authenticate with your SMTP username and password.
  • The the path to Perl is:



Correct file permissions for a Perl script

Permissions are often set very leniently in order to avoid permissions problem. This is not a good idea. Your Perl scripts should have the appropriate permissions depending on the function of that particular script.

First, all scripts should be set to the owner (you) having read, write and execute privilege (rwx) regardless of the function of the Perl script.

Next, you should ask yourself if you want people (visitors) to your Web site to be able to execute the Perl script. This is most likely the case. Under these conditions, your script would be set to world readable and execuable (r-x). Do not give everyone write permission on the Perl script; it is not necessary and may lead to problems.

If your script is not going to be executed through the Web and only you will be executing the script through Telnet (there are various reasons for having a script operate under these conditions), then you set the script to no world permissions (---).

The group permissions should be set to read and executable (r-x) if the script is to be executable via the Web. Otherwise, set your group permissions to nothing (---).

With this information, you have the following permissions breakdown:

Executed via the Web by anyone: chmod 755 

Often times, a Perl script will open a file for writing. This is the case in guestbooks and bulletin boards, where the information is received from the form and written to a certain file. The permissions of this particular file are now important.

Many times, the author of a Perl script you use on your account will require you to set this file to rwxrw-rw-, or chmod 766, which allows write access to the world. This is not a good idea and is unnecessary.

Files that need to be written to by way of a Perl script can be set to the default permissions of rw-r--r--, or chmod 644. This will work fine with our setup.

Finally, never set your file permissions to rwxrwxrwx, or chmod 777. This is not necessary, may cause a security problem on your Web site, and will cause your Perl script to not execute at all.


ASCII or Binary Mode Uploads

You should always upload your Perl scripts in ASCII mode via FTP. If you upload your scripts in binary mode, the scripts will not work and you will get an "Internal Server Error: Premature End of Script Headers" error (500 Internal Server Error). It is very important to remember to only upload your Perl scripts in ASCII mode.


Images used with Perl Scripts

Your cgi-bin folder is a special folder for your scripts. Place all static content, including HTML and image files under your docs folder or its sub-folders.


Internal Server Errors

There are several causes for this problem:

  • Make sure your path to Perl executable is set as #!/usr/bin/perl in your first line of Perl scripts.
  • You have set the executable bit to your files, in other words, you need to set the file permissions (chmod) to 755.
  • You need to place all your Perl scripts under cgi-bin folder or its subfolders.
  • Make sure you upload all your Perl scripts in ASCII mode in your FTP client.


Was this article helpful?
0 out of 0 found this helpful