Skip to content

Installing and configuring PEAR packages

The PHP Extension and Application Repository (PEAR) provides reusable PHP libraries that simplify development. On ruachost.com, you can install and configure PEAR packages to extend your applications with features like database interaction, e‑mail handling, and XML processing.

  • A framework and distribution system for reusable PHP components.
  • Includes libraries for databases, caching, authentication, and more.
  • Helps developers avoid reinventing common functionality.

Many PEAR packages are already available system‑wide on shared hosting servers.

  • Log in via SSH and run:

    Terminal window
    pear list
  • This displays all packages currently installed for your account.

  1. Log in to cPanel.
  2. Go to Software → PHP PEAR Packages.
  3. Search for the package you want (e.g., Mail).
  4. Click Install Now.
  • If you cannot install via cPanel, open a Support ticket

  • The Ruachost Support team can install the package for you.

Note: The pear install command requires superuser access and is not available on shared hosting accounts.

After installing a PEAR package, configure PHP to locate it.

  1. Create or edit a custom php.ini file in your application directory.

  2. Add the include path:

    include_path = ".:/usr/lib/php:/usr/local/lib/php:/home/USERNAME/php"

    Replace USERNAME with your account name.

  3. Save the file.

This ensures your scripts can load PEAR packages correctly.

Example using the Mail package:

<?php
require_once "Mail.php";
$headers = array(
'From' => 'sender@example.com',
'To' => 'recipient@example.com',
'Subject' => 'Test message'
);
$mail_object = Mail::factory('mail');
$mail_object->send('recipient@example.com', $headers, 'Hello from PEAR Mail!');
?>
  • Always check if a package is already installed before requesting support.
  • Use Composer for modern PHP projects when possible, but PEAR remains useful for legacy applications.
  • Keep your include path updated if you move scripts to new directories.
  • Test installations with simple scripts before deploying to production.