cPanel & WHM

How to Install the PHP GMP Extension on a cPanel Server (EasyApache 4)

Install GNU MP (GMP) on your cPanel server for high-performance arithmetic and cryptographic applications.

Short answer: On a cPanel server, install GMP through EasyApache 4. In WHM, open Software > EasyApache 4, click Customize, open PHP Extensions, search for gmp, enable it for each PHP version your sites use, then review and provision. You can also install the package from the command line. Confirm it with php -m.

What GMP is and why applications need it

GMP stands for the GNU Multiple Precision Arithmetic Library. It works with integers far larger than the 64-bit numbers PHP handles natively. The PHP gmp extension exposes this library to PHP code through functions such as gmp_add(), gmp_mul() and gmp_powm().

Applications ask for GMP when they need exact maths on very large numbers. Typical examples are cryptography libraries, which can use GMP to speed up key operations, and code that calculates with large IDs or IPv6 address ranges. If an installer or plugin reports that the GMP extension is missing, it needs this extension enabled for the PHP version the site runs on.

GMP or BCMath?

PHP has a second extension for large numbers, BCMath. The two are often confused, and some applications accept either one.

GMP BCMath
Works with Whole numbers (integers) Decimal numbers stored as strings
Speed Faster for large integer maths, because it uses the GMP C library Slower, but needs no external library
Typical use Cryptography, big IDs, IPv6 ranges Money and other decimal calculations

Check your application’s requirements. If it asks for GMP, install GMP. If it lists BCMath, install that instead, from the same PHP Extensions page.

Before you start

  • ✓ Root access to WHM, or root SSH access to the server.
  • ✓ The PHP versions your sites use. Check them in WHM > Software > MultiPHP Manager.
  • ✓ A recent backup. EasyApache 4 rebuilds PHP packages, and a rebuild restarts Apache and PHP-FPM.
  • ✓ A quiet time for the change, because sites can be briefly unavailable while services restart.

If the server runs CloudLinux with PHP Selector, some accounts may use alt-php instead of the EasyApache 4 PHP versions. The steps for that case are in Method 3.

Method 1: install GMP in WHM (EasyApache 4)

  1. Log in to WHM as root.
  2. Go to Software > EasyApache 4.
  3. Next to Currently Installed Packages, click Customize.
  4. Open the PHP Extensions page.
  5. Search for gmp. One row appears for each installed PHP version.
  6. Turn on the GMP row for every PHP version your sites use.
  7. Click Review, check the list of changes, then click Provision.
  8. Wait for provisioning to finish. EasyApache 4 restarts Apache and PHP-FPM when it is done.

Enable GMP for each PHP version separately. A site on PHP 8.3 will not see an extension installed only for PHP 8.4.

Method 2: install GMP from the command line

EasyApache 4 PHP versions are installed as packages, so you can add GMP with the package manager. Package names follow the PHP version, so search for the exact name on your server before you install it.

# 1. List the EasyApache 4 PHP versions installed on the server
ls /opt/cpanel | grep ea-php

# 2. Find the GMP package for one version (PHP 8.3 in this example)
dnf list available 'ea-php83-php-*' | grep -i gmp      # AlmaLinux, Rocky Linux, CloudLinux 8 and later
yum list available 'ea-php83-php-*' | grep -i gmp      # CloudLinux 7

# 3. Install the package the search returned
dnf install ea-php83-php-gmp

# 4. Restart PHP-FPM so it loads the new extension
/scripts/restartsrv_apache_php_fpm

Repeat steps 2 and 3 for each PHP version your sites use. If the search returns nothing, that PHP version may not offer GMP, or the server cannot reach the cPanel repositories. Check the repository setup before you try another method.

Method 3: CloudLinux PHP Selector (alt-php)

On CloudLinux servers with PHP Selector, an account can run an alt-php version instead of an EasyApache 4 version. In that case, enable the extension for the account:

  1. Log in to cPanel for the account.
  2. Open Select PHP Version (PHP Selector).
  3. Check that the selected version is the one the site uses.
  4. Open the Extensions list, tick gmp, and save.

If you are not sure which PHP an account runs, compare the version shown in MultiPHP Manager with the one in PHP Selector. Only one of them is active for the site.

Check that GMP is loaded

Check each PHP version directly, because the php command on the server may point to a different version than your site uses.

# EasyApache 4 PHP 8.3
/opt/cpanel/ea-php83/root/usr/bin/php -m | grep -i gmp

# The default php command
php -m | grep -i gmp

Each command should print gmp. To check from the site itself, create a temporary file in its document root with <?php phpinfo();, open it in a browser, and search the page for “gmp”. Delete the file straight away, because it shows details about your server.

Troubleshooting

Problem Likely cause What to do
GMP does not appear in EasyApache 4 The PHP version does not offer it, or the package list is out of date Run the package search from Method 2. Update the server with /scripts/upcp if packages are missing.
Installed, but the application still says it is missing The site uses a different PHP version or handler Check MultiPHP Manager and PHP Selector, then enable GMP for the version the site actually uses.
Installed, but not loaded after the change PHP-FPM has not restarted Run /scripts/restartsrv_apache_php_fpm, then check again with php -m.
Sites fail after provisioning Another change was included in the same EasyApache 4 profile Review the last provision in EasyApache 4, revert to the previous profile if needed, and restore from backup.

Keep PHP itself up to date

Installing an extension is a good moment to check that each PHP version is still supported and patched. See our PHP version support guide for the current support dates, and the PHP critical security update guide for the October 2026 fixes. Other extensions are added the same way, as shown in our cURL on cPanel guide.

Need help with this?

Need GMP or another PHP extension set up for you? Our server management team can install and test it on your server.

See server management plansContact @CustomerPanel

Frequently asked questions

Do I need to restart anything after installing GMP?

EasyApache 4 restarts Apache and PHP-FPM when provisioning finishes. If you installed the package from the command line, restart PHP-FPM with /scripts/restartsrv_apache_php_fpm so the extension loads.

Do I have to install GMP for every PHP version?

Yes. Each PHP version has its own extensions, so enable GMP for every version your sites use.

Why does php -m show GMP but my site says it is missing?

The command-line php may be a different version from the one the site uses. Check the PHP version for the domain in MultiPHP Manager or PHP Selector, then check that exact version.

Can I still compile GMP from source on cPanel?

It is not recommended. Compiling extensions by hand bypasses EasyApache 4, so cPanel updates can break or overwrite them. Use the EasyApache 4 packages instead.


Sources