Sunday, 4 November 2012

how to install pear on wamp server

Let's have look at how to install go-pear in wamp server

First download go-phear : download PEAR or save file as .phar from http://pear.php.net/go-pear

Save above file where your php.exe is located means your php executable directory.

Now open cmd as administrator - right click on cmd and click on run as administrator. And run following command.
Move to your php executable directory and type :

C:\wamp\bin\php\php5.3.0>php -d phar.require_hash=0 PEAR/go-pear.phar(drive may change as per your installed drive)

Reply to “Are you installing a system-wide PEAR or a local copy?” with “local” or "system". When prompted, set each directory to the following scheme (note: the php version may differ):

Below is a suggested file layout for your new PEAR installation. To change individual locations, type the number in front of the directory. Type 'all' to change all of them or simply press Enter to accept these locations.

1. Installation base ($prefix): C:\wamp\bin\php\php5.3.0
2. Temporary directory for processing: C:\wamp\bin\php\php5.3.0\tmp
3. Temporary directory for downloads: C:\wamp\bin\php\php5.3.0\tmp
4. Binaries directory: C:\wamp\bin\php\php5.3.0
5. PHP code directory ($php_dir): C:\wamp\bin\php\php5.3.0\pear
6. Documentation directory: C:\wamp\bin\php\php5.3.0\pear\docs
7. Data directory: C:\wamp\bin\php\php5.3.0\pear\data
8. User-modifiable configuration files directory: C:\wamp\bin\php\php5.3.0\pear\cfg
9. Public Web Files directory: C:\wamp\www
10. Tests directory: C:\wamp\bin\php\php5.3.0\pear\tests
11. Name of configuration file: C:\wamp\bin\php\php5.3.0\pear.ini
12. Path to CLI php.exe: C:\wamp\bin\php\php5.3.0\.

1-12, 'all' or Enter to continue:

And your installation will begin.

At the end it will generate a .reg file, on which you have to double click to enter this information into registry.

Install again using C:\wamp\bin\php\php5.3.0>php go-pear.phar which will remove if any error were generated.

Still You are not done: (your version and directory may differ)
  • open your php.ini file which is located in  C:\wamp\bin\php\php5.3.0\

    • find "Paths and Directories"
      Add - include_path = ".;C:\wamp\bin\php\php5.3.8\pear"

  • Now open php.ini file from your apache directory  C:\wamp\bin\apache\apache2.2.11\bin\php.ini

    • find "Paths and Directories"
      Add - include_path = ".;C:\wamp\bin\php\php5.3.8\pear"
Restart your apache server

Change the Windows PATH environment variable to include c:\wamp\bin\php\php5.3.0 (in Windows Vista: Start->Control Panel->System and Maintenance->System->Advanced System Settings->Environment Variable. Edit the PATH system variable and add c:\wamp\bin\php\php5.3.0). 

Now start a Windows command prompt and type pear. It will list all the pear commands. pear list will list all PEAR packages current installed. Use pear install -o <package> to install a package ( -o will install required dependencies).


You may need to add the following environment variables to the environment.

(create .htaccess file and put following code into .htaccess file and save .htaccess file into your PEAR directory)

php_value include_path “ C:\wamp\bin\php\php5.3.0\PEAR”
php_value error_reporting 0 

PHP_PEAR_BIN_DIR=C:\wamp\bin\php\php5.3.0
PHP_PEAR_DATA_DIR=C:\wamp\bin\php\php5.3.0\PEAR\data
PHP_PEAR_DOC_DIR=C:\wamp\bin\php\php5.3.0\PEAR\docs
PHP_PEAR_INSTALL_DIR=C:\wamp\bin\php\php5.3.0\pear
PHP_PEAR_PHP_BIN=C:\wamp\bin\php\php5.3.0\php.exe
PHP_PEAR_SYSCONF_DIR=C:\wamp\bin\php\php5.3.0
PHP_PEAR_TEST_DIR=C:\wamp\bin\php\php5.3.0\PEAR\tests

And you can install PEAR front end too. for viewing on wamp server

c:\wamp\bin\php\php5.3.0>pear install PEAR_Frontend_Web


During installation if you find and DEPRECATED message then just ignore them as they are not ERROR.

After a package is installed, the documentation for the package will be in a newly created folder under C:\wamp\bin\php\php5.3.0\PEAR\docs\.
The C:\wamp\bin\php\php5.3.0\PEAR\test\ folder typically contains a sample test php script, to test the package.
Some packages are in beta. To install them you first need to set the preferred release to beta: pear config-set preferred_state beta. Then after installing the beta package do pear config-set preferred_state stable.

PEAR_Frontend_Web package, which was in Beta when this was written, is a web-based front-end alternative to the command line PEAR package manager. To install it open a Windows command prompt and do:
c:\wamp\bin\php\php5.3.0>pear install PEAR_Frontend_Web