How to Install PHP PECL Extensions

PECL extensions are third-party extensions for PHP. These extensions often add new built-in functions to PHP that do not exist in the core PHP language. PECL extensions are often used to provide a way for PHP code to interact with additional system libraries.

Install the Compiler

As PECL extensions are compiled programs, you must first install a compiler and related tools and libraries. To install the compiler, run the following command on your server as root.

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

Installing PECL Extensions

In the examples shown, replace "X.Y" with your app's PHP version (for example, "5.6" or "7.2"). To install a PECL extension for multiple PHP versions, repeat the installation for each PHP version.

Now that you've installed the compiler as shown above, SSH into your server as root and run the following command to install the extension. Replace EXTENSION with the name of the extension you want to install.

sudo peclX.Y-sp install EXTENSION

However, each extension may require different development libraries before it can be compiled and installed.

See our documentation on installing specific PECL extensions.

If you are installing an extension we do not have a tutorial for, 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.

Uninstalling PECL Extensions

To uninstall a PECL extension, see our documentation on removing PHP extensions.

Last updated: February 26, 2018