PEAR is short for PHP Extension and Application Repository and is pronounced just like the fruit. The purpose of PEAR is to provide:
- A structured library of open-source code for PHP users.
- A system for code distribution and package maintenance.
- A standard style for code written in PHP, specified here.
- The PHP Extension Community Library (PECL), see more.
PEAR is a community-driven project governed by its developers. PEAR's governing bodies are subdivided into the PEAR Group, Collectives, and a President. PEAR's constitution (adopted in March 2007) defining these groups is documented here. The PEAR project was founded in 1999 by Stig S. Bakken and quite a lot of people have joined the project. Please see: About PEAR.
PEAR is pre-installed and available for use on the Grid. The path to PEAR is
/usr/bin/pear-stable. The installation directories have already been added to your include_path so nothing special is needed to use our pre-installed PEAR modules. The list of pre-installed modules is as follows:
Package Version State Archive_Tar 1.3.1 stable Console_Getopt 1.2 stable HTML_Template_IT 1.1 stable Net_UserAgent_Detect 2.0.1 stable PEAR 1.4.9 stable
Before you start, be sure to have these handy:
- Your site number
- SSH access
READ ME FIRST
This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.
Installing custom PEAR packages
Some developers may want to install PEAR packages that we have not included. Due to the nature of grid hosting, there are a few caveats involved in getting PEAR modules installed on the Grid. To install a new PEAR package on your Grid:
1. Log into your Grid via SSH. For more information, please read this article.
2. To install custom PEAR packages, you must do a complete PEAR installation in your home directory. Start by telling the global version of PEAR to generate a configuration file for your home directory. We will also run a few other commands to set up your PEAR environment:
/usr/bin/pear config-create $PWD .pearrc /usr/bin/pear config-set download_dir /home/00000/data/pear/download /usr/bin/pear config-set cache_dir /home/00000/data/pear/cache
3. Let's make the directories you'll need and set the permissions:
Be sure to replace 00000 with your site number. For instructions on how to identify your site number, please see: What is my site number?
mkdir /home/00000/data/pear/ mkdir /home/00000/data/pear/cache mkdir /home/00000/data/pear/download chmod -R 755 /home/00000/data/pear/
4. Next, we'll tell the global version of PEAR to install another version in your home directory so your user can have write access:
/usr/bin/pear install -o PEAR
5. Let's add the path to your new PEAR installation to your bash_profile so you won't have to type the full path anymore. Open or create a file in your home directory named '.bash_profile' and add the following line:
6. Set the Download Directory:
pear config-set download_dir /path/to/folder
7. Now you may install any PEAR packages you like with the 'pear' command. As an example, let's install the newest Mail package:
pear install -o Mail
Now that PEAR is installed locally, you must alter your include_path so your scripts know where to look for the new packages. There are three ways to do this:
A. Globally --
Edit your custom php.ini to include the new path to PEAR. This change will affect all scripts on your site. For more help with editing your php.ini file, please see this article: How can I edit php.ini file? Simply add a line to your php.ini file that reads:
include_path = ".:/home/00000/data/pear/php"
B. On a per directory basis --
Use an .htaccess file to change your include_path for all php scripts in a single directory. This change does not affect scripts outside of this directory. Create an .htaccess file in the desired directory and add the following line:
php_value include_path '/home/00000/data/pear/php'
Please be sure to substitute your site number for the '00000' numerals. For more help with creating .htaccess files, please see our article: Using .htaccess files.
C. For a single script --
This change will only work for the script. Edit your script and add the following line near the top:
Please be sure to substitute your site number for the '00000' numerals.
READ ME FIRST
This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is unsupported by (mt) Media Temple. Please take a moment to review the Statement of Support.
- Create a file called
vhost.confwith the following contents:
If you would like to make PEAR available via https, follow the instructions below but create vhost_ssl.conf instead of vhost.conf. If you would like to enable this for subdomains, you must create the appropriate vhost.conf files for all subdomains that you need and then reconfigure the main vhost.conf file.
<Directory "/var/www/vhosts/example.com/httpdocs"> php_admin_value open_basedir "/var/www/vhosts/example.com/httpdocs/:/tmp/:/usr/share/pear/" php_admin_value include_path "/var/www/vhosts/example.com/httpdocs/:/tmp/:/usr/share/pear/" </Directory>
- Reconfigure your webserver so it will look for your new vhost.conf file by doing this:
/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain example.com
- Finally, you must restart Apache, this can be done through Plesk or by executing the following commands:
/etc/init.d/httpd stop /etc/init.d/httpd start