Control panels

Install PHP extensions on cPanel (EasyApache 4 and PECL)

Add PHP extensions such as intl, imagick or redis on a cPanel server with EasyApache 4 packages or the WHM PECL installer, then confirm them with php -m.

IntermediateLinux server4 min read

Applications often fail with errors like "Class Imagick not found" or "intl extension missing". On cPanel, each PHP version is a separate EasyApache 4 build, so an extension must be installed for every version that needs it. This guide covers the two supported ways to do that and how to prove the extension loads.

Note: You buy one from cPanel or a partner and install it on your Linux VPS.

Before you start

  • Root access to WHM and SSH on a cPanel server.
  • The PHP version the site uses. Check WHM » Software » MultiPHP Manager.
  • The exact extension name the application needs, for example intl, imagick, redis, sodium or gmp.

Always prefer an EasyApache 4 package when one exists. cPanel builds and updates it with the rest of PHP. Use PECL only when there is no package.

Option 1: EasyApache 4 in WHM

  1. In WHM, open Software » EasyApache 4.
  2. Next to Currently Installed Packages, click Customize.
  3. Open the PHP Extensions tab.
  4. Type the extension name in the search box, for example intl. You see one package per PHP version, such as ea-php82-php-intl and ea-php83-php-intl.
  5. Switch on the package for every PHP version your sites use.
  6. Go to Review, check the list of changes, then click Provision.

EasyApache installs the packages and restarts Apache and PHP-FPM. Sites stay online, but expect a short pause during the restart.

Option 1b: install the same packages from SSH

EasyApache 4 packages are normal system packages, so you can also install them with the package manager. This is handy for scripting.

AlmaLinux and Rocky Linux

Bash
dnf list available 'ea-php83-php-*' | grep -iE 'intl|imagick|redis'
dnf install ea-php83-php-intl

Ubuntu

Bash
apt update
apt search ea-php83-php 2>/dev/null | grep -iE 'intl|imagick|redis'
apt install ea-php83-php-intl

Search before you install. Package availability differs between PHP versions and operating systems, and some extensions are only available through PECL.

Restart PHP-FPM so the pools load the new extension:

Bash
/scripts/restartsrv_apache_php_fpm

Option 2: PECL in WHM

If the extension has no EasyApache package, WHM can build it from PECL.

  1. In WHM, open Software » Module Installers.
  2. Click Manage next to PHP PECL.
  3. Choose the PHP version from the menu at the top.
  4. In Find a PHP PECL, search for the extension, for example redis.
  5. Click Install and wait for the build log to finish.
  6. Repeat for every PHP version that needs it.

PECL compiles the extension from source, so the server needs build tools. If the build fails, the log shows the missing library, such as ImageMagick development headers for imagick.

Warning: PECL builds are not updated by EasyApache. After a PHP minor update, check the extension still loads, and reinstall it from Module Installers if it does not.

Check it works

Each EasyApache PHP version has its own binary. List the loaded modules for the version your site uses:

Bash
/opt/cpanel/ea-php83/root/usr/bin/php -m | grep -iE 'intl|imagick|redis'

Expected output:

imagick
intl
redis

The command line uses the same php.ini as PHP-FPM for that version, but to be certain the web side sees it, create a test file in the site's document root:

Bash
echo '<?php var_dump(extension_loaded("intl"));' > /home/USER/public_html/ext-test.php
chown USER:USER /home/USER/public_html/ext-test.php

Open https://example.com/ext-test.php. It should print bool(true). Delete the file when you are done.

Troubleshooting

  • Extension shows in php -m but the site still errors: the site runs a different PHP version. Check MultiPHP Manager and install the package for that version too.
  • PECL build fails with a missing header: install the development package for the library, for example ImageMagick-devel on AlmaLinux, then retry. Prefer the EasyApache package if one exists.
  • "Module already loaded" warning: the extension is enabled twice, for example by a package and a PECL build. Remove one of them and check the .ini files in /opt/cpanel/ea-php83/root/etc/php.d/.
  • Redis extension installed but connections fail: the extension is only the client. You still need a Redis server running and reachable.
  • Provision fails in EasyApache: read the log it shows. Conflicts usually mean a package from another repository; remove it, then provision again.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.