This is possible, but this is not for the faint of heart.
Within the cPanel & WHM ecosystem there is a way to add compiled modules - it is not documented for a reason. There is a script that exists on all cpanel systems at /usr/local/cpanel/build-tools/ called "buildperl" this will modify a Makefile.PL and run it so that it will install properly to cpsrvd's perl.
For example, here's a script that will install XML::Parser (used in SOAP::Lite) to a cpanel system.
note: this script may be buggy, this was done as a proof of concept. use at your own risk.
Code:
#!/usr/bin/perl
# XML::Parser installer for cPanel
# Tested with version 11.30.1
use strict;
use warnings;
use File::Copy;
use File::Copy::Recursive 'rcopy';
use Cwd;
use lib '/usr/local/cpanel';
use Cpanel::SafeRun::Simple ();
if ( !-e '/usr/local/cpanel/version' ) {
die "this server does not have cPanel installed on it";
}
my $base = getcwd();
chomp $base;
my $cpperl = '/usr/local/cpanel/perl';
my $arch = Cpanel::SafeRun::Simple::saferun('uname -i');
chomp $arch;
if ( $arch ne 'x86_64' ) {
$arch = 'i686';
}
print "Copying the perl module 'English' into cPanel's perl environment\n";
copy 'libs/English.pm', '/usr/local/cpanel/perl/English.pm';
print "Copying the perl module 'Text::ParseWords' into cPanel's perl environment\n";
copy 'libs/ParseWords.pm', '/usr/local/cpanel/perl/Text/ParseWords.pm';
print "Extracting the XML::Parser v2.41 package\n";
mkdir 'tmp';
print Cpanel::SafeRun::Simple::saferun('tar vzxf libs/XML-Parser-2.41.tar.gz');
if ( !-d 'XML-Parser-2.41') {
print "XML Parser failed to extract. Installation cannnot continue\n";
exit 1;
}
print "Copying File::Temp into the temporary location for XML::Parser usage\n";
chdir 'XML-Parser-2.41';
mkdir 'inc/File';
copy "$base/libs/Temp.pm", 'inc/File/Temp.pm';
print "Putting Config.pm into place\n";
copy '/usr/local/cpanel/perl/' . $arch . '-linux/Config.pm', '/usr/lib/perl5/5.6.2/' . $arch . '-linux/Config.pm';
print "Setting up ExtUtils in cPanel's perl environment\n";
rcopy '/usr/local/cpanel/perl/ExtUtils/', '/usr/lib/perl5/5.6.2/ExtUtils/';
copy '/usr/local/cpanel/perl/config.h', '/usr/local/cpanel/perl/x86_64-linux/CORE/';
print "Running XML::Parser's Makefile.PL\n";
print Cpanel::SafeRun::Simple::saferun('export ULCP=/usr/local/cpanel/perl; /usr/local/cpanel/build-tools/buildperl Makefile.PL SITEPREFIX=$ULCP PERL_LIB=$ULCP PERL_ARCHLIB=$ULCP/' . $arch . '-linux INSTALLPRIVLIB=$ULCP INSTALLSITELIB=$ULCP SITELIBEXP=$ULCP SITEARCHEXP=$ULCP/' . $arch . '-linux INSTALLARCHLIB=$ULCP/' . $arch . '-linux INSTALLMAN3DIR=/usr/local/cpanel/3rdparty/man');
print "Running XML::Parser's `make`\n";
print Cpanel::SafeRun::Simple::saferun('make');
print "Running XML::Parser's `make install`\n";
print Cpanel::SafeRun::Simple::saferun('make install');
print "Complete!\n";
chdir $base;