How to fix Pear install issues after installing from Repositories

Pear (PHP Extension and Application Repository) is a useful tool for installing PHP extensions and repositories on Linux, Max and Windows.  It allows for adding functionality to PHP, without the risk of code found randomly on the Internet. In case you are unaware, adding code without knowing that the source is reliable, can open any number of vulnerabilities for your server, since PHP can access other programs, utilities and resources.

Today I wanted to install the a package from the PECL  repositories.  Rather than downloading, compiling and installing directly from PECL, I decided that I would go ahead and install Pear, as it is a resource I frequently use.  One issue that can arise after installing Pear is missing dependencies.

Here is the process I used for installing Pear on Ubuntu 16.04.

cd ~/src

wget http://pear.php.net/go-pear.phar

sudo php go-pear.phar

I changed option 9 to reflect the path to my websites, but otherwise did not need to change any options.

To check the install run

pear version

In addition to listing the expected output:

pear installation - 1

I also got a (very) long list of errors, a small part in the image below:

pear installation - 2

The problem involves snmp and the mibs that go with it. To fix the dependencies, is a simple matter.  Below is the command to install the dependencies required:

sudo apt-get install libsnmp-dev libsnmpkit-dev snmp-mibs-downloader

Once this is complete, check the install with pear version, this time the output is:

pear installation - 3

Now to update Pear so that the repositories can be accessed:

sudo pear update-channels

pear installation - 4

Something to keep in mind if you are running PHP 7.0, many extensions have not yet been updated to accommodate the new version.  If you plan to install specific modules, you may need to install a secondary version of PHP.

I am needing an Log module, so I will be using the example pear/Log.

sudo pear install –alldeps pear/Log

pear installation - 5

By using –alldeps all recommended optional modules (such as pear/SASL2) are automatically installed as a part of the installation, otherwise you have to individually add them.  As noted on the final line you can add on specific addons, not deemed necessary by default, like this

sudo pear install MDB2#mysqli

pear installation - 6

If you are missing any further dependencies, they will be listed when the compilation fails, as well as any packages that are recommended, such as

sudo pear install pecl/spidermonkey

pear installation - 7

Unfortunately, libjs is not directly downloadable as a package.  To find packages that will provide it you need to install a program that is invaluable:

sudo apt-get install apt-file

sudo apt-file update

sudo apt-file jsapi.h

Apt-file is an amazingly useful tool for finding dependencies.  It returns a list of packages that will provide jsapi.h.  Download and install.  Then you can go ahead and install the php module,

sudo pear install pecl/spidermonkey

No further dependency issues, and a nice little module for your use.

Expert Tip

How to fix Pear install issues after installing from Repositories

If the issue is with your Computer or a Laptop you should try using Reimage Plus which can scan the repositories and replace corrupt and missing files. This works in most cases, where the issue is originated due to a system corruption. You can download Reimage by clicking the Download button below.

Download Now

I'm not interested

Close