Overview
Perl modules allow you to extend cPanel & WHM's functionality. For example, you can use Perl modules to add functions to cPanel & WHM.
Warning:
Before you install a module, make certain that it will function correctly with the cPanel-provided Perl environments. For more information, read our Guide to Perl in cPanel & WHM documentation.
Note:
In the examples throughout this document, Module::Name
is the name of the custom Perl module that you wish to install.
Custom modules that ship with cPanel & WHM
Warning:
Our upgrades to Perl may break custom code and modules that you used in previous versions of cPanel & WHM.
cPanel & WHM versions 56 through 62 ship with binaries that we compile against Perl version 5.22. This change directly affects any custom Perl code that you execute from cPanel binaries. It is critical that you test your plugins and hook code against Perl 5.22 to ensure that they continue to work correctly.
Install modules to the system Perl binary
To install a Perl module to the system's Perl environment (/usr/bin/perl
), use one of the following methods:
Method | Description | Example command |
---|---|---|
Install from the WHM interface. | To install a module to the system Perl environment, use WHM's Module Installers interface (WHM >> Home >> Software >> Module Installers). Note: To use this interface, you must have compiler access. | |
Install from the command line with the /scripts/perlinstaller script. | The Notes: When you use this script, you can include the
| /scripts/perlinstaller Module::Name |
Install from the command line with the cpan command. | The cpan command calls the CPAN utility. You must include, as an argument, the name of the module that you wish to install. Make certain that you use the CPAN convention for the module name. | cpan Module::Name |
Install modules to the cPanel Perl installation
To install a Perl module to the cPanel-included Perl installation (/usr/local/cpanel/3rdparty/bin/perl
), use the following method:
Method | Description | Example Command |
---|---|---|
The /usr/local/cpanel/3rdparty/perl/522/bin/cpanm tool. | When you use this tool, you must include, as an argument, the name of the module that you wish to install.
| /usr/local/cpanel/3rdparty/perl/522/bin/cpanm -i Module::Name |
Confirm that your module installed correctly
To confirm that the modules you installed to the system's Perl binary are functional, run the following command, where Module::Name
is the name of the module:
/usr/bin/perl -MModule::Name -e 'print $Module::Name::VERSION . "\n"'
To confirm that the modules you installed to the cPanel-included Perl installation are functional, run the following command, where Module::Name
is the name of the module:
/usr/local/cpanel/3rdparty/perl/514/bin/perl -MModule::Name -e 'print $Module::Name::VERSION . "\n"'
If the command responds with the version of the module that you installed, the installation was successful.
Manage installed modules
The /scripts/perlmods
script allows you to use the Perl::Mod
module in order to manage the modules on your system.
Use the following flags to troubleshoot module installations:
-l
— Use thePerl::Mod
module to list all of the installed modules for your system.-
-s
— Use thePerl::Mod
module to search for an installed module. -
-u
— Use thePerl::Mod
module to uninstall modules.
Troubleshoot module problems
Error logs
Error logs provide additional insight into problems on your server. cPanel & WHM writes STDERR
(standard error) output to the /usr/local/cpanel/logs/error_log
file whenever it encounters an error.
Use strace
Some errors require that you use the strace
(system trace) command to view additional output that does not write to the /usr/local/cpanel/logs/error_log
file.
To view additional error information, run the following command while the system experiences the problem:
strace -s 4096 -fvt -o /root/strace.issue.at.hand -p `cat /var/run/cpsrvd.pid`
@INC errors
When you encounter @INC
array errors, you will see a message that resembles the following example in the /usr/local/cpanel/logs/error_log
file:
Can't locate DB_File.pm in @INC (@INC contains: /usr/local/cpanel /usr/local/lib/perl5/5.8.8/x86_64-linux /usr/local/lib/perl5/5.8.8 /usr/local/lib/perl5/site_perl/5.8.8/x86_64-linux /usr/local/lib/perl5/site_perl/5.8.8 /usr/local/lib/perl5/site_perl .) at /scripts/spamassassin_dbm_cleaner line 14.
In this example, the system could not locate the Perl module. The error message also lists the locations in which the system searched for the module.
If you encounter this error, perform the following actions to resolve the problem:
- Place a copy of the module in one of the locations that the error message lists.
- Create a symlink from one of the listed locations to the location of the module.
- Resolve an issue in the module itself during build time.
To view the current @INC
array paths, run the perl -V
command as the root
user. The system will return output that resembles the following example:
Built under linux Compiled at Jan 28 2011 08:49:59 @INC: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8
Additional documentation