How to change location of the pear.ini for php 5.4 and 5.5 on Windows

When PEAR installs itself on Windows it places pear.ini file in the system folder c:\Windows by default. Which sometimes needs to be changed after all. And sometimes it is not possible for some reasons (not sure why, probably a bug in PEAR installation scripts) to change this location during the installation. Then we need to change this location when PEAR is already installed and in use.

First check the current PEAR configuration pear config-show

C:\>pear config-show
Auto-discover new Channels     auto_discover    1
Default Channel                default_channel
HTTP Proxy Server Address      http_proxy       <not set>
PEAR server [DEPRECATED]       master_server
Default Channel Mirror         preferred_mirror
Remote Configuration File      remote_config    <not set>
PEAR executables directory     bin_dir          C:\lib\php\PEAR
PEAR documentation directory   doc_dir          C:\lib\php\PEAR\docs
PHP extension directory        ext_dir          ./ext
PEAR directory                 php_dir          C:\lib\php\PEAR\pear
PEAR Installer cache directory cache_dir        c:\temp\pear\cache
PEAR configuration file        cfg_dir          C:\lib\php\PEAR\cfg
PEAR data directory            data_dir         C:\lib\php\PEAR\data
PEAR Installer download        download_dir     C:\temp
PHP CLI/CGI binary             php_bin          C:\lib\php\php.exe
php.ini location               php_ini          c:\lib\php
--program-prefix passed to     php_prefix       <not set>
PHP's ./configure
--program-suffix passed to     php_suffix       <not set>
PHP's ./configure
PEAR Installer temp directory  temp_dir         C:\temp
PEAR test directory            test_dir         C:\lib\php\PEAR\tests
PEAR www files directory       www_dir          C:\lib\php\PEAR\www
Cache TimeToLive               cache_ttl        3600
Preferred Package State        preferred_state  stable
Unix file mask                 umask            0
Debug Log Level                verbose          1
PEAR password (for             password         <not set>
Signature Handling Program     sig_bin          C:\Program Files
Signature Key Directory        sig_keydir       c:\lib\php\pearkeys
Signature Key Id               sig_keyid        <not set>
Package Signature Type         sig_type         gpg
PEAR username (for             username         <not set>
User Configuration File        Filename         c:\lib\php\pear.ini
System Configuration File      Filename         c:\lib\php\pearsys.ini

Two last lines here show the location for PEAR configuration files that needs to be changed.

Some users reports that PEAR creates a key in Windows registry but this is not always true. And PEAR works fine without that key.

What always works is an environment variable PHP_PEAR_SYSCONF_DIR. It should points to the pear.ini file location.