How to install PHP PECL extensions

in PHP

PECL is a repository for PHP Extensions, providing a directory of all known extensions and hosting facilities for downloading and development of PHP extensions.

Install the compiler

sudo apt-get install gcc make autoconf libc-dev pkg-config

Install extensions

To install the extension execute the next command:

sudo /usr/local/<php path>/bin/pecl install <extension name>

And follow the instructions. At the end you should be notice to add the extension to php.ini. The file where to add it is:/usr/local/<php path>/etc/conf.d/modules.ini

- <php path>: is the folder where each PHP build was installed. Here is the path name of each of the available PHP versions:

  • PHP 5.5: h4d-php-5.5
  • PHP 5.6: h4d-php-5.6
  • PHP 7: h4d-php-7
  • PHP 7.1: h4d-php-7.1

-<extension name>: is the name of the pecl package. Browse pecl packages here:

Important: You have to install the extension in all the PHP versions where you need it.

An example

If you want to install mongodb for the hosting4devs PHP 7 version you must execute the next commands:

  • Install the PECL extension:
    sudo /usr/local/h4d-php-7/bin/pecl install mongodb

  • Add the module to the module loader ini file:
    sudo bash -c "echo >> /usr/local/h4d-php-7/etc/conf.d/modules.ini"

  • Restart PHP
    sudo service h4d-php7.1-fpm restart

If you are installing an extension please send us the steps you used to install the extension so we can add documentation for it.

If you are having trouble installing a particular extension, please contact support.