How to install GMP for PHP7 on Ubuntu

To install GMP for PHP7.0 on Ubuntu, run: sudo apt-get install php7.0-gmp

Make sure your php.ini contains the following: extension=php_gmp.so

To find out where your php.ini is located, run: php --ini


For PHP 7.2:

sudo apt-get install php7.2-gmp

The new way in PHP 7 to install extensions is to just write "php-EXTENSION" In this case it's as simple as:

sudo apt-get install php-gmp