Thursday, 10 September 2009

Fixing a Suddenly “Broken” cPanel Installation

Sometimes out of nowhere cPanel will just break. You don’t know why, you don’t know when, and you don’t know how…it just happens. In my experience it’s usually when a cPanel update fails for some reason or perl is borked, but either way – it just sucks. This article will go over how to fix a malfunctioning cPanel installation or botched upgrade.

How do I know it’s broken?

It’s usually pretty obvious, but when you get error every time you open cPanel or WHM, or get perl errors when you try to run any of the scripts in /scripts, accompanied by a slew of errors in the cPanel error log (/usr/local/cpanel/logs/error_log), it’s clear that cPanel and/or Perl is malfunctioning.

The good thing is, cPanel and Perl can usually be fixed rather easily.

First things first, if you’re just getting a simple Perl error, you may just be missing a couple Perl modules. Take for example an error that looks like this:


Can't locate IPC/Open3.pm in @INC (@INC contains: /scripts /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/pkgacct line 22.
BEGIN failed--compilation aborted at /scripts/pkgacct line 22.


This references a Perl module that does not exist, in which case you can just install it. The name of the Perl module is indicated in the error, just replace the slash with double-colons and pass it through /scripts/perlinstaller :
/scripts/perlinstaller IPC::Open3

If that fixes the problem, great…you may have to do this a couple more times for other perl modules. But you know there’s a REAL problem when the Perl installer fails, or the perl module is made by cPanel and doesn’t exist in the standard CPAN repos. In that case, you may need to resync the cPanel scripts.

First, run the following command to get your cPanel version branch:
cat /usr/local/cpanel/version

This should return something like 11.24.5-STABLE_38506, indicating that the branch is STABLE. Other branches indicated could be RELEASE, CURRENT, BETA, or EDGE. Use this branch to download the scripts folder from the cPanel repo. The below example is for STABLE:
wget -O scripts.tar.bz2 http://httpupdate.cpanel.net/cpanelsync/STABLE/scripts.tar.bz2
tar -xvC / -j -p -f scripts.tar.bz2
chmod 755 /scripts/cpanelsync
/scripts/cpanelsync httpupdate.cpanel.net /cpanelsync/STABLE/scripts /scripts
/scripts/upcp –force

Problem still not fixed? Try reinstalling Perl:
cd /usr/src
wget http://layer2.cpanel.net/perl588installer.tar.gz
tar -xvzf perl588installer.tar.gz
cd perl588installer
./install

Then run /scripts/upcp –force again to reinstall the cPanel files

No comments:

Post a Comment