cPanel & WHM servers include multiple Perl environments.
Your version of cPanel & WHM determines which Perl environments are available:
For directions on how to install a Perl module, read our Perl Module Installation documentation.
Problems with CGI and Perl scripts are common, and may be due to a wide variety of reasons.
To troubleshoot the problem, use following methods.
The following examples troubleshoot the
Make certain that the script is executable. To display the permissions for a script, run the
ls -la example.cgi command as the
root user, where
example.cgi represents the name of the script:
# ls -la example.cgi -rw-r--r-- 1 burst wheel 41 May 29 16:04 example.cgi
In this example, the script has the following permissions:
To change the permissions of the script, run the following command:
chmod 755 example.cgi
This command changes the permissions of the script to the following permissions:
For more information about these file system permissions, read about numeric notation.
If the server still returns a 500 error, a code error may be the reason.
Add the following code to the top of your script:
#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser);
This change redirects errors to the browser and does not display a 500 error.
To check the code for errors, run the following command:
perl -w ./example.cgi
This command runs the script with the warnings flag, which displays any errors in the code:
# perl -w ./example.cgi Can't find string terminator '"' anywhere before EOF at ./example.cgi line 3.
This message indicates that the Perl script cannot run because it contains fatal errors.
Search online for tutorials on Perl and how to troubleshoot specific errors.
If you found the error within the code, run the script from the command line again:
# perl -w ./example.cgi Hello World !
If the script works at the command line but does not work in a browser, the script may not send the correct content type to the browser.
In the above example, assume that the
example.cgi script works in the shell, but does not display in the browser. To fix this problem, add the following line near the top of the script:
print "Content-type: text/html\n\n";
When you run the updated script, you will see the following output:
# perl -w ./example.cgi Content-type: text/html Hello World !
If the script does not work in the browser with the correct content type, the
suexec module may cause the problem. The Apache webserver often includes the
suexec module as a security measure. It forces a sanity test on the permissions of CGI scripts before it runs them. A sanity test checks the permissions of scripts and determines whether they are accessible.
module completes the sanity test, it forces the scripts to run with the permissions of the account owner.
To check for proper permissions, run the
The output will resemble the following example:
# ls -la total 6 drwxr-xr-x 2 burst wheel 512 May 29 16:04 . drwxr-xr-x 3 burst wheel 512 May 29 16:03 .. -rwxr-xr-x 1 burst wheel 78 May 29 16:24 example.cgi
The directory "." is the current working directory. Set this directory to the following permissions:
If you are unsure about problems with a script, examine the
suexec log file in the
/usr/local/apache/logs/ directory. Use the
tail -f suexec_log command to watch the log file, and then try to load the script in your browser to see the error that the script caused.
Confirm that the account's user owns the file. Sometimes, when a password or group file becomes corrupted, you will see a number rather than a username.
When you run the
ls -la command and a file is corrupted, the output will resemble the following example:
# ls -la total 6 drwxr-xr-x 2 8840 8840 512 May 29 16:04 . drwxr-xr-x 3 burst wheel 512 May 29 16:03 .. -rwxr-xr-x 1 8840 8840 78 May 29 16:24 example.cgi
To fix this error, run the
chown burst.burst * command, where
burst represents the name of the account's owner, to change the owner of the script and the directory back to the correct owner.
Even if the owner appears to be correct, it is possible for a script to show the correct name but to actually be associated with a different user ID. This issue appears in the
If you have performed all of these steps and the script still does not work, submit a support ticket.
suexec module breaks your CGI scripts, run the
tail -f command on the
/usr/local/apache/logs/suexec_log log file to find the error.
The following output is an example of error output from a Perl script that is found in Apache's error log (
[Tue Mar 26 09:13:16 2002] [error] [client x.x.x.x] (2)No such file or directory: getgrgid: invalid groupid 32015 [Tue Mar 26 09:13:16 2002] [error] (2)No such file or directory: exec of /home/username/public_html/utility.cgi failed [Tue Mar 26 09:13:16 2002] [error] [client x.x.x.x] Premature end of script headers: /home/username/public_html/script.cgi
To fix this error, run the following command:
chmod 644 /etc/group
If you continue to experience an issue, check the permissions on the
passwd file and
If that fails to fix the issue, submit a support ticket.
You can run multiple versions of PHP 5 only if your system runs EasyApache 4. EasyApache 4 is available in cPanel & WHM versions 11.52 and later.
You can also run PHP 7 if your system runs EasyApache 4 and cPanel & WHM version 54 or later.
To install PHP 7, perform the following steps:
yum install ea-php70. For more information, read our How to Locate and Install a PHP Version or Extension documentation.
We recommend that you allow your operating system's distribution to control the system Perl installation.
To install and activate Zend Guard Loader in EasyApache 3, run the
script at the command line as the
To install and activate Zend Guard Loader in EasyApache 4, use yum or WHM's EasyApache 4 interface (WHM >> Home >> Software >> EasyApache 4).
Because the PHP module does not have control over the
.htaccess files, place a customized
php.ini file in the directory that contains your PHP scripts.
For more information about how to install modules to cPanel & WHM, read our Perl Module Installation documentation.