How to install and configure PEAR packages

PEAR (PHP Extension and Application Repository) packages are reusable PHP code libraries that can greatly simplify web site development. There are PEAR packages for interacting with databases, handling e-mail, processing XML, and much more.

Install a PEAR package

Before you try to install a PEAR package, make sure it is not already installed. For example, our shared hosting servers already have several PEAR packages that are pre-installed systemwide. To see which PEAR packages are currently available for your web account, log in using SSH and then type the following command:

pear list

If the PEAR package that you want is not listed, then you can install it using one of the following methods.

A2 Hosting does not support installation of PECL (PHP Extension Community Library) modules in our shared hosting environment. PECL modules can only be installed on VPS and Dedicated hosting accounts.
Method #1: Use cPanel

If your A2 Hosting account includes cPanel, you can use it to install PEAR packages. For information about how to install PEAR packages using cPanel, please see this article.

After the PEAR package is installed, you must configure the PHP include path. To do this, follow this procedure.

Method #2: Submit a support ticket

If you have installed PEAR packages before on other systems, you may have used the pear install command. However, this command requires superuser access, which is not available on shared hosting accounts. If you are unable to install a PEAR package using cPanel, an A2 Hosting administrator can install it for you. If you need further assistance, please open a support ticket with our Guru Crew on the Customer Portal at https://my.a2hosting.com.

After the PEAR package is installed, you must configure the PHP include path. To do this, follow this procedure.

Configure the PHP include path

After you install a PEAR package for the first time using one of the methods above, you must configure the PHP include path. Otherwise, your PHP script files will be unable to locate the PEAR packages that you installed. After you configure the PHP include path, you do not need to do so again for subsequent PEAR package installations.

If you are using pre-installed systemwide PEAR packages in your code, you do not need to follow this procedure. This procedure only applies to PEAR packages that you have installed yourself.

To configure the PHP include path:

  1. If you do not already have a custom php.ini file in the directory where your script file is located, set one up now. For information about how to set up a custom php.ini, please see this article.
  2. Open the php.ini file and locate the line that starts with:
    include_path
  3. Add the PHP extension path. For example, if the existing line is:

    include_path = ".:/usr/lib/php:/usr/local/lib/php"

    Change the line to:

    include_path = ".:/usr/lib/php:/usr/local/lib/php:/home/USERNAME/php"
  4. You can now include the PEAR package in script files located in the same directory.

More Information

For more information about PEAR packages, please visit http://pear.php.net.

Article Details

  • Level: Intermediate

Related Articles

Show More

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.