Updated: 16 November 2026 · Applies to: AlmaLinux 10 (PHP 8.3), Ubuntu 24.04 (PHP 8.3), Debian 13 (PHP 8.4), cPanel EasyApache 4

On most servers the GMP math library is already installed as a system library, so what you usually need is the PHP GMP extension that uses it. Install php-gmp with your package manager, restart PHP, and check that gmp appears in php -m. On a cPanel server, install the EasyApache 4 package for your PHP version instead.

GMP (the GNU Multiple Precision Arithmetic Library) does exact arithmetic on numbers far larger than a normal 64-bit integer. PHP code uses it through functions such as gmp_add() and gmp_pow(); billing software, cryptography libraries and some payment modules ask for it.

AlmaLinux, Rocky Linux and other RHEL-based servers

  1. Install the PHP extension (it pulls in the gmp library automatically):
    dnf install php-gmp
  2. Restart PHP-FPM so the web server sees the new extension:
    systemctl restart php-fpm
  3. Check that it is loaded:
    php -m | grep gmp
    Output:
    gmp

The package adds its own settings file, /etc/php.d/20-gmp.ini, so you do not need to edit php.ini.

Ubuntu and Debian

  1. Install the extension:
    apt install php-gmp
  2. Restart PHP-FPM. The service name contains your PHP version: php8.3-fpm on Ubuntu 24.04, php8.4-fpm on Debian 13.
    systemctl restart php8.3-fpm
    If you use Apache with mod_php instead of PHP-FPM, restart Apache:
    systemctl restart apache2
  3. Check it:
    php -m | grep gmp

php-gmp is a small package that points to the extension for the distribution's default PHP version (php8.3-gmp on Ubuntu 24.04, php8.4-gmp on Debian 13). If you run another PHP version, install the matching package, for example php8.2-gmp.

cPanel servers (EasyApache 4)

According to cPanel, EasyApache 4 names its PHP extension packages ea-php##-php-module, where ## is the PHP version. For GMP on PHP 8.3 on AlmaLinux or Rocky Linux:

dnf install ea-php83-php-gmp

On a cPanel server running Ubuntu:

apt install ea-php83-php-gmp

You can also do it in WHM: go to Home » Software » EasyApache 4, click Customize on the current profile, open PHP Extensions, switch on the GMP extension for each PHP version you use, then review and provision. Our step-by-step guide with screenshots is How to install GMP Math on cPanel. For other extensions, see How to Install PHP extensions on cPanel server.

Test that GMP works

This prints 2 to the power of 100, a number too large for a normal PHP integer:

php -r 'echo gmp_strval(gmp_pow(2, 100)), PHP_EOL;'

Output:

1267650600228229401496703205376

If you get Call to undefined function gmp_pow(), the extension is not loaded for that PHP binary. On servers with several PHP versions, the command-line php may not be the version your website uses: check the site in your control panel's PHP settings, or create a page with phpinfo() and look for a gmp section.

Installing the GMP library itself (for compiling software)

If a program you are building from source needs the GMP headers, install the development package:

dnf install gmp-devel

On Ubuntu and Debian:

apt install libgmp-dev

In our test, AlmaLinux 10 shipped GMP 6.2.1 and Ubuntu 24.04 and Debian 13 shipped GMP 6.3.0.

Shared hosting

On shared hosting you cannot install packages yourself. If your plan uses CloudLinux, tick gmp in the PHP Selector extension list (see How to Enable or Disable PHP Extensions in Plesk via CloudLinux Selector or How to Manage PHP Extensions in DirectAdmin via CloudLinux Selector); otherwise ask your host's support team. On a KVM VPS you have full root access and can follow the steps above.

Official documentation: PHP manual, GMP and cPanel, How to locate and install a PHP version or extension.

Was this answer helpful?

Still stuck? Open a ticket