In Cpanel, performing an EasyApache update to Apache 2.x & PHP 5.x breaks PEAR more often than not.  Cpanel admins and users are left with only the very basic PEAR modules, and are unable to use the Module Installer front-end due to error messages indicating that every package one attempts to install is invalid.
     Attempting to install Net_URL, for instance, results in the following:

downloading Net_URL-1.0.15.tgz …
Starting to download Net_URL-1.0.15.tgz (6,303 bytes)
…..done: 6,303 bytes
Could not get contents of package “/root/tmp/pear/cache/Net_URL-1.0.15.tgz”. Invalid tgz file.
Download of “pear/Net_URL” succeeded, but it is not a valid package archive
Error: cannot download “pear/Net_URL”
Download failed
install failed

     The problem is caused by differences in the way PHP 5.2.x parses code, and can be fixed by manually patching the listContent function in PEAR’s Archive_Tar package.  Open /usr/local/lib/php/Archive/Tar.php and look at the offending Line 220:

//            if (!$this->_extractList('', $v_list_detail, "list", '', '')) {
            $x = $this->_extractList('', $v_list_detail, "list", '', '');
            if (!$x) {

     We commented it out, and added two more lines.  Now, from both the command-line & WHM interface, everything magically works.

Note: In some instances (depending on your OS, Cpanel version & build options — multiple servers show no uniformity), you’ll have to make the same change to /usr/lib/php/Archive/Tar.php.

Leave a Reply