PECL (PHP Extension Community Library) is a repository for PHP extensions that are not included in the core PHP distribution. You can use PECL to easily install and manage PHP extensions.
Step 1: Ensure PECL is Installed
PECL is included with PHP-PEAR, so you may need to install it first:
For cPanel/WHM servers:
yum install ea-phpXX-php-pear ea-phpXX-php-devel -y
Replace XX
with your PHP version (e.g., ea-php82-php-pear
for PHP 8.2).
For other Linux distributions:
apt install php-pear php-dev -y # Debian/Ubuntu
yum install php-pear php-devel -y # CentOS/RHEL
Step 2: Install the PHP Extension Using PECL
To install an extension, use:
pecl install extension_name
For specific PHP versions on cPanel/WHM:
/opt/cpanel/ea-phpXX/root/usr/bin/pecl install extension_name
Replace XX
with the PHP version (e.g., ea-php82
for PHP 8.2).
Example:
pecl install zstd
Step 3: Enable the Installed Extension
After installation, you may need to manually enable the extension in the PHP configuration file.
Add the extension to the
php.ini
or create a.ini
file:echo "extension=extension_name.so" >> /etc/php.d/extension_name.ini
For cPanel/WHM:
echo "extension=extension_name.so" >> /opt/cpanel/ea-phpXX/root/etc/php.d/extension_name.ini
Restart your web server to apply changes:
Step 4: Verify the Installation
Check if the extension is installed:
php -m | grep extension_name
or
php -i | grep extension_name
If the extension appears in the output, it has been successfully installed.