Sunday, July 15, 2012

Install PEAR for Shared Hosting

PEAR is undeniably a good source of PHP code library that will make programmers' life a lot easier. Installing PEAR on Windows/IIS platform is easy especially when you have admin access to your PC/server.

When it comes installing PEAR in a shared hosting environment, admin access is null and there are workarounds that need to be addressed in order to use the PEAR library in the restricted platform.

Here are the steps I use:

  1. Go to
    Copy the content and save it as go-pear.php or other names that you prefer

  2. Upload the go-pear.php to your server and launch the PHP codes by browsing the php such as logging on to http://yourdomain/yourpath/go-pear.php

  3. During setup, you need to find out the path of your PHP executable. You can easily find out by running a PHP like this:

    echo `which php`;
    // or echo PHP_BIN if this doesn't work;

  4. After the installation is done, you can now remove the go-pear.php for security reason. You will also be given the absolute path to your PEAR here.

    Note: To use PEAR without any problems you need to add your PEAR Installation path (/xxxxxx/xxxxxxxx/xxxxxxx/......./PEAR) to your include_path.

  5. Test your PEAR. You can try the following simple PHP code:


    set_include_path('./PATH_TO_YOUR/PEAR/' . PATH_SEPARATOR
    . get_include_path());

    require_once 'PEAR.php';

    If it returns a bool(true), you are all set. Enjoy! :)

    Note: You need to make sure the include path is there every time you need PEAR. This is for shared hosting environment. If you have admin access, you can easily skip this by adjusting the PHP.ini file.

No comments:

Post a Comment