Guide to Installing Additional PHP Modules Using PECL
In our panel, we provide the option to enable PHP modules that are not listed in the GUI.
For instructions on activating PHP modules that are available within the GUI, please refer documentation.
This document outlines the steps for installing PHP modules that are not mentioned in the GUI, including third-party modules.
Installing Third-Party PHP Modules Using PECL
For third-party PHP modules not listed in the GUI, clients can still install them manually using PECL (PHP Extension Community Library). PECL is a repository for PHP extensions that provide additional functionality to PHP, such as performance enhancements, database drivers, and more.
PECL is already pre-installed on your server as part of our latest update. No additional setup is required. Follow the steps below to install any PHP extension.
Steps to Install a PECL Extension
1. Access the Server via SSH
Use an SSH client (e.g., PuTTY or terminal) to log in to your server.
We are using the latest PHP version, 8.4, as an example. The PECL path varies for each PHP version, make sure to modify the command to match the version of PHP you are using.
2. List installed PECL extensions
/opt/cpguard/packages/php84/bin/pecl list
3. Install the Required Extension
Run the following command, replacing EXTENSION with the name of the PHP extension you wish to install:
/opt/cpguard/packages/php84/bin/pecl install EXTENSION
Note: Ensure to replace the PHP version with the appropriate one as needed.
Example: /opt/cpguard/packages/php84/bin/pecl install imagick
4. Install the compiler
PECL extensions need to be compiled from the source code.
To install the necessary compiler, execute the following command on your server as the root user.
export DEBIAN_FRONTEND=noninteractive
sudo apt-get -y install gcc g++ make autoconf libc-dev pkg-config
5. Configure PHP to Load the Extension
After the extension is installed, configure PHP to load it by creating a new EXTENSION.ini
file in the conf.d
directory:
sudo bash -c "echo extension=EXTENSION.so > /opt/cpguard/packages/php84/etc/conf.d/EXTENSION.ini"
Example:
sudo bash -c “echo extension=EXTENSION.so > /opt/cpguard/packages/php84/etc/conf.d/imagick.ini”
6. Restart PHP-FPM
To apply the changes, restart PHP-FPM:
sudo service php84-fpm restart
Remove a PECL extensions
If you no longer need an extension you’ve installed, you can remove the extensions.
/opt/cpguard/packages/php84/bin/pecl uninstall EXTENSION
Example:
/opt/cpguard/packages/php84/bin/pecl uninstall imagick
The output of the above command will include the following message:
Unable to remove "extension=EXTENSION.so" from php.ini
This message can be safely ignored.
To apply the changes, restart PHP-FPM:
sudo service php84-fpm restart