How to Install Multiple PHP Extensions using PECL via SSH?

When configuring PHP on Linux hosting, installing PHP extensions for all versions might be necessary. To achieve this, you'll need to run the installer for each individual version.

To Install a PHP Extension

  1. To install a PHP extension, use the pecl command for the respective PHP version:

/opt/cpanel/ea-php72/root/usr/bin/pecl

/opt/cpanel/ea-php73/root/usr/bin/pecl

EasyApache 4 supports multiple PHP versions, and the command varies for each version, as illustrated in the example above with PECL locations for PHP 7.2 and PHP 7.3.

  1. To install a module, use the pecl install command:

/opt/cpanel/ea-php73/root/usr/bin/pecl install xmldiff

To Install Multiple PHP Extensions

To install multiple PHP extensions, iterate through each PHP version using the following command:

ls /opt/cpanel/ea-php{72..80}/root/usr/bin/pecl 2>/dev/null | while read phpversion; do $phpversion install xmldiff; done

The provided code loops through PHP versions from 7.2 to 8.0, installing the xmldiff extension for each version.

This example demonstrates how to install either a single PHP extension or multiple extensions simultaneously using PECL on a Linux server.

 


Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 206