Many users have a shared provider that grants access to a system-wide PEAR installation. However, in many cases, it is advantageous to have a local copy of PEAR that can be used for packages that are not installed by the host provider. There are ways of installing PEAR both for users with a telnet/ssh shell access and users who only have ftp access.
To install PEAR through SSH, you can use this command sequence to set up a local copy of PEAR:
$ pear -s -c ~/.pearrc -d doc_dir=~/pear/docs -d ext_dir=~/pear/ext \ -d php_dir=~/pear/lib -d data_dir=~/pear/data -d test_dir=~/pear/tests \ -d cache_dir=~/pear/cache -d bin_dir=~/pear/bin |
This will create a local configuration file in a file in your home directory named .pearrc. In addition, it will create a directory structure based on a subdirectory of your home directory named pear that contains all of the packages that you install.
Then, if you add ~/pear/bin to your path as the first entry in .bashrc (or whatever your startup file is), and run the command:
$ pear -c ~/.pearrc install Archive_Tar PEAR Console_Getopt XML_RPC |
You will have a local version of PEAR that supersedes the system's copy. To use the files you have installed, you should set your PHP include_path in either the code that uses your PEAR packages like so:
<?php ini_set('include_path', '~/pear/lib' . PATH_SEPARATOR . ini_get('include_path')); ?> |
Or, in an .htaccess file for apache using php_value.
In order to install a local copy of PEAR through ftp, you must have an ftp client that can set permissions on upload. First, create a directory that is NOT in your publicly accessible web space, and name it anything you'd like. Set it to be readable and writable by any user (permissions 0777). Then, download a copy of http://go-pear.org and save it as go-pear.php. Upload go-pear.php to a subdirectory of your publicly accessible web space. It is a very good idea to password-protect the directory containing go-pear.php with an .htaccess file.
Next, browse to the go-pear.php file. If your web address is http://www.example.com, you have placed go-pear.php in public_html/install/go-pear.php, and http://www.example.com will browse to public_html/, then browse to http://www.example.com/install/go-pear.php. Follow the installation prompts. When asked where to install PEAR, choose the directory you created to be readable and writable by any user. You will need to know the location of the cli version of PHP. To find this, browse to this script and copy the output:
<?php echo `which php`; // if this does not work, also try echo PHP_BIN; ?> |
After PEAR has been installed, you can use the web installer to install and upgrade packages just as you would with any other PEAR installation. To use the files, you must set the include path in scripts on the website.
<?php ini_set('include_path', '~/pear/lib' . PATH_SEPARATOR . ini_get('include_path')); ?> |