09/08 2009

Install PEAR on a third party server

Have you ever been frustrated with your Hosting company because they couldn't or wouldn't install the PEAR library for you.

You can truly make your Web Applications completely independant of any hosting limitations by installing you own copy of PEAR.

Thankfully, my kind hosting provider has installed PEAR but I relied on the following method for years and its great.

I couldn't find any useful tutorials about this and have decided to help you guys out there by sharing my tinkerings and hard slog to get this dang thing working.

What I am aiming for is to include the PEAR modules in a folder outside the document root for the site and into the include path. Many people seem to think it is as easy as downloading the Modules you want and sticking them on a php enabled server but unfortunately this is not the case. You need to have a certain base core for PEAR to function correctly.

This is where the magic go-pear comes in. If you browse over to, you can see a script that if you save to your web server somewhere you can browse to, it will run you through a sequence that will allow you to install and manage your PEAR repository.

Then you click on the next link to show the configuration screen into which you place the location on your local server, you want the base files for pear, including any optional core modules (including the very useful MDB2), installed.

As you can see from the above, go-pear automatically detects your web servers root directory and will use this as the base install directory by default. I would (and have) installed pear outside of the document root itself and into the central repository where I have all my web application tools and modules. For the purposes of demonstration I have left the paths alone.

The first screenshot above is simply to show you a healthy install process being carried out. The one above shows you what the screen should look like once the install has completed.

A bug on Windows servers

Things never run smoothly in our world and the go-pear script is no exception. My main issue with hosting is that I am currently using a Windows based server from a third party. The go-pear script installs perfectly and on the final screen you are instructed to click on to the front end of the local pear repository, unfortunately when I did this, I got the following screen

Have no fear, there is a solution. For some reason when writing this application the people who developed PEAR left out a vital file for Windows users. I found the answer in one of the base pear php files which goes a bit like this:

if (!isset($pear_user_config) || $pear_user_config == '') {
 if (OS_WINDOWS) {
 $conf_name = 'pear.ini';
 } else {
 $conf_name = 'pear.conf';

This led me to the root of where pear was installed and I saw the pear.conf file, which had all the paths I had entered during install. As the code suggests however, OS_WINDOWS is looking for pear.ini. After jigging around and saving pear.conf as pear.ini, low and behold if the front end didn't spring into life:

From here, it is just like maintaining your pear modules from the command line on your local development server, but much easier! If you want to install pear outside the document root (which I would recommend) you may be wandering how you can get to this front-end screen. Simply have a file, or action if you are using a framework, that includes the index.php file called in the demo above and it's fine.

There is a security warning telling you to make this page secure, you should be able to do this either using security measures directly on your server or by building it into your own Web Application like I have and denying access to this page, you don't want everyone installing and uninstalling pear modules for you. Enjoy...

One Response to Install PEAR on a third party server

  1. shri says:

    i m a php developer .i want to host php/pear based sites.

Leave a Reply

Your email address will not be published. Required fields are marked *

This article is in the Server category. Here are some other related articles also in this category.