Install a PHP extension manually
This method is not applicable for installing PHP extensions in CloudLinux.
Native PHP version
Execute the command below to install an extension for the native PHP version:
CentOS
yum install <package name>Debian
apt install <package name>Alternative PHP version
You can install an extension for the alternative PHP version:
- using the package manager Pecl;
- from the source code.
Install an extension using the package manager Pecl
Extension installation example:
Install the packages:
CentOS
yum install autoconf gcc zlib-develDebian
apt install autoconf gcc zlib1g-devAdditional packages may be required when you install other extensions.
Install the extension:
/opt/<PHP version directory>/bin/pecl install <extension name>Connect the extension for a required PHP version:
echo extension=<extension name> >> /opt/<PHP version directory>/etc/php.d/<extension name>.iniFor example:
echo extension=memcache.so >> /opt/<PHP version directory>/etc/php.d/<extension name>.ini
Install from the source code
Let's install env as an example::
Download and extract the archive with the extension source code:
cd /tmp wget -O env.tar.gz http://pecl.php.net/get/env tar xzvf env.tar.gz cd env-0.2.1/Run the configuration and setup process:
/opt/<version directory PHP>/bin/phpize ./configure --with-php-config=/opt/<PHP version directory>/bin/php-config && make && make installEnable the extension globally for the required PHP version:
echo 'extension=env.so' > /opt/<PHP version directory>/etc/php.d/20-env.ini
The extension setup process may require additional packages that are not described in this article.