How do you run Perl scripts as CGI on Loopia’s UNIX web hosting?

You run Perl as a CGI (Common Gateway Interface) script at Loopia by placing the script in the cgi-bin directory of a (sub)domain on our Unix platform, giving it the .cgi file extension and 755 permissions, and pointing its shebang line at /usr/local/bin/perl.

We support Perl 5.42. Last checked: 2026-09-22.

Requirements for running a Perl CGI script

To run a CGI script at Loopia, the following is required:

  1. The (sub)domain must be on one of our Unix servers. If it isn’t, change the web platform to Unix first.
  2. The script must be located in the cgi-bin directory. If the directory doesn’t exist, create it as yourdomain.com/public_html/cgi-bin. To run the script from another directory, see “Another directory” below – otherwise the script will not run.
  3. The file extension must be .cgi for this to work.
  4. The file permissions must be 755 (CHMOD). You can set this with an FTP client.
  5. The path to Perl is /usr/local/bin/perl – this is the path to use in the script’s shebang line.
  6. The path to Sendmail is /usr/sbin/sendmail.

Another directory

If you don’t place the script in the cgi-bin folder, you need to change some Apache settings with an .htaccess file. Create a file called .htaccess in the public_html folder and add the following lines:

Options +ExecCGI
AddHandler cgi-script .cgi

The same .htaccess mechanism is used for Python scripts – see How do you run Python scripts as CGI on Loopia’s UNIX web hosting?

Example script

Below is an example of what a script can look like to run on a website:

#!/usr/local/bin/perl
print "Content-Type: text/html; charset=utf-8\n\n";
print "Hello and welcome to my test script.";

Save it as, for example, test.cgi in cgi-bin, set the permissions to 755 and open it in your browser.

Support scope for scripts

Our support does not cover script-related problems that are not caused by one of our servers or similar, and we are unable to assist you with your programming.

If you have a problem with a script and would like us to look at it, send the path to the script, a brief explanation of what you are trying to do and any error messages you receive to support@loopia.com.

The following external resources are useful for Perl and CGI (Common Gateway Interface) developers:

Was this article helpful?

Related Articles