How can I install PHP PEAR on DSM 7.0 or above?

How can I install PHP PEAR on DSM 7.0 or above?

Purpose

This article provides steps to install PHP PEAR via SSH. Installing PHP PEAR via Package Center is no longer available on DSM 7.0 and above.

Resolution

Install PHP PEAR

  1. Sign in to DSM as root via SSH (refer to this article for detailed instructions).
  2. Download the go-pear.phar file through wget:
    wget https://pear.php.net/go-pear.phar
  3. Run the go-pear.phar file with your PHP package. We take PHP 7.3 as an example in the following command:
    sudo PHP_PEAR_PHP_BIN=/usr/local/bin/php73 php73 go-pear.phar
  4. Follow the onscreen instructions to continue the setup. We suggest storing the PHP code directory and Data directory in shared folders, which you can back up and restore via DSM.

    Below is a suggested file layout for your new PEAR installation. To change individual locations, type the number in front of the directory. Type 'all' to change all of them or simply press Enter to accept these locations.

    • 1. Installation base ($prefix)-------------------: /usr/local
    • 2. Temporary directory for processing------------: /tmp/pear/install
    • 3. Temporary directory for downloads-------------: /tmp/pear/install
    • 4. Binaries directory----------------------------: /usr/local/bin
    • 5. PHP code directory ($php_dir)---------------------------: /usr/local/share/pear
    • 6. Documentation directory-----------------------: /usr/local/docs
    • 7. Data directory------------------------------------------: /usr/local/data
    • 8. User-modifiable configuration files directory-: /usr/local/cfg
    • 9. Public Web Files directory--------------------: /usr/local/www
    • 10. System manual pages directory----------------: /usr/local/man
    • 11. Tests directory------------------------------: /usr/local/tests
    • 12. Name of configuration file-------------------: /usr/local/etc/php73/pear.conf

    1-12, 'all' or Enter to continue:

  5. Enter "N" when the following message pops up to ask if you wish to modify the php.ini file.
    Would you like to alter php.ini </usr/local/etc/php73/cli/php.ini>?
  6. Press the Enter key.
  7. PHP PEAR is installed on your DSM.

Activate PEAR's command-line interface (optional)

Add the include_path directive to the pear.ini file by running a command in the following format (based on PHP 7.3):

sudo echo "include_path = .:the path of PHP code directory" > /usr/local/etc/php73/cli/conf.d/pear.ini

By default, the path of PHP code directory is "/usr/local/share/pear".

Make PEAR available for PHP profiles (optional)

  1. Go to DSM Web Station > Script Language Settings > PHP.
  2. Select a PHP profile and click Edit > Core.
  3. Enter ".:the path of PHP code directory" in the include_path field, e.g., ".:/usr/local/share/pear".
  4. Click Save.
Purpose
Resolution
Install PHP PEAR
Activate PEAR's command-line interface (optional)
Make PEAR available for PHP profiles (optional)
Further reading