Zero logo

PHP - PEAR Auto Install go-pear

This page covers automatic installation of PEAR using go-pear; it is provided for reference only. The following covers Pear instalation along with one of its components (classes) for testing.

Pre-configured

Apache and PHP (modules) configuration files have been pre-configured as follows:

Apache httpd.conf

Contains an Alias and Directory directive
to map the folder us_pear into Apache.

Alias /us_pear "${US_ROOTF}/home/us_pear/"
<Directory "${US_ROOTF}/home/us_pear/">
  Options Indexes Includes
  AllowOverride All
  Require all granted
</Directory>

PHP config files:
php_development.ini, php_production.ini and php_test.ini
Contain the include path shown on the right.


include_path = ".;${US_ROOTF}/home/us_pear/PEAR"

File .htaccess

Running go-pear.php generates a long list of depreciated warning. These are suppressed using an htaccess file. This htaccess file also restricts access to localhost only. Create the file as follows:

  • Copy the .htaccess from folder www into folder UniServerZ\home\us_pear (Windows makes it difficult to create a file named .htaccess hence the copy)
  • Edit this copied file and delete all it’s content and add the following lines:
Description .htaccess

The first three lines restricts access to local host.
The php_flag display_errors 22527 is the same as setting
Error_reporting = E_ALL & ~E_DEPRECATED in php.ini
Suppresses depreciated warnings.

UniServerZ\home\us_pear\.htaccess
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
php_flag display_errors 22527

Install and run go-pear

The following details how to download, install and run the go-pear installer.

  1. Create a new folder us_pear in folder UniServerZ\home (Already created).
  2. Download the file from http://pear.php.net/go-pear and save it as go-pear.php
  3. Save this in folder UniServerZ\home\us_pear (created in step 1)
  4. Start UniController from UniController start Apache
  5. Type the following into your browser: http://localhost/us_pear/go-pear.php
  6. Welcome to go-pear 1.1.6 displayed. Click next
  7. Configuration page displayed
    • Select MDB2 database abstraction layer
    • Click Install
  8. Wait for Installation Completed to be displayed.
  9. Click Start Web Frontend of the PEAR Installer. Note: This will produce a 404 error Not Found.
  10. The URL http://localhost/us_pear/\index.php is incorrect change this to http://localhost/us_pear/index.php
    • Note: The above will highlight another error:
      Warning: Can not find config file, please specify the $pear_user_config variable in /us_pear/index.php
  11. To resolve the above edit file UniServerZ\home\us_pear\index.php as follows:
    • Note in addition to resolving the above we take the opportunity to make this configuration file portable.
Change section shown on right:

To correct the above uncomment
Line //$pear_user_config = ''; and insert the
correct path.

However with a few extra changes the file is
made portable as shown in the next section.

UniServerZ\home\us_pear\index.php - Top section
/**
 * Put this file in a web-accessible directory as index.php (or similar)
 * and point your webbrowser to it.
 */

// $pear_dir must point to a valid PEAR install (=contains PEAR.php)
$pear_dir = 'C:\UniServerZ\home\us_pear/PEAR'; // default of install

// OPTIONAL: If you have a config file at a non-standard location,
// uncomment and supply it here:
//$pear_user_config = '';

// OPTIONAL: If you have protected this webfrontend with a password in a
// custom way, then uncomment to disable the 'not protected' warning:
//$pear_frontweb_protected = true;

To:

$us_path = realpath('.') sets the variable to
the full path of this document for example:
C:\UniServerZ\home\us_pear

This variable is used to construct paths:
$pear_dir = $us_path.'\PEAR';
$pear_user_config = $us_path.'\pear.conf';

We are using the .htaccess file to restrict
access hence this line is set to true:
$pear_frontweb_protected = true;

/**
 * Put this file in a web-accessible directory as index.php (or similar)
 * and point your webbrowser to it.
 */

$us_path = realpath('.'); // Determine full path to this file portability

// $pear_dir must point to a valid PEAR install (=contains PEAR.php)
$pear_dir = $us_path.'\PEAR'; // default of install

// OPTIONAL: If you have a config file at a non-standard location,
// uncomment and supply it here:
$pear_user_config = $us_path.'\pear.conf';

// OPTIONAL: If you have protected this webfrontend with a password in a
// custom way, then uncomment to disable the 'not protected' warning:
$pear_frontweb_protected = true;
  1. Now re-enter the url: http://localhost/us_pear/index.php and the web-front end is displayed.
  2. From the left menu click Configuration link
  3. Change PEAR configuration file directory: from C:\php\pear\cfg to C:\UniServerZ\home\us_pear
  4. Click Submit button

Note: The above produces configuration file C:\UniServerZ\home\us_pear\pear.conf this file as it stands is NOT portable. When UniController is started it checks the current server location and updates this configuration accordingly. If you need to change paths ensure they are set for the current server location.

Summary

The pear module was created using the above procedure and once installed is ready to run. To install packages see section Using PEAR Frontend.

An alternative to using go-pear for installation is to manully instal Pear convered on page PEAR Manual Install.