How to Install Gmp for PHP7 on Ubuntu

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

unable to enable php-gmp for php7.4 with ddev

Usually, you should add packages through adding webimage_extra_packages to your configuration (see the documentation):

webimage_extra_packages: [php7.4-gmp]

On restarting the containers using ddev restart, this configuration is applied and the package gets installed. Have you tried this?

Using this way helps to keep this package tied to the container ddev uses. While adding it to a running container (as you did) is not explicitly wrong, this package will be removed again if you change the PHP version or upgrade ddev. Through using the configuration, you can ensure that this package is installed again if the container images change.

How to install gmp extension for php 7.2 using MAMP on OSX

Here is how i did in 2020

Download php from source https://github.com/php/php-src/releases pick the version which is matching with MAMP PHP version you have.

Copy the extension you want. Here we are copying gmp directory.

Paste it to /Applications/MAMP/bin/php/php7.4.1/include/php/ext

(Make sure to move to your MAMP php version directory)

cd /Applications/MAMP/bin/php/php7.4.1/include/php/ext/gmp

Then run phpize command

/Applications/MAMP/bin/php/php7.4.1/bin/phpize

Step 5:

./configure --with-php-config=/Applications/MAMP/bin/php/php7.4.1/bin/php-config

It outputs following

Then

make

Then

make install

Its installed now.

You can confirm it by

/Applications/MAMP/bin/php/php7.4.1/bin/php -i | grep gmp

gmp support => enabled

If you didn't see gmp support enabled, you may need to add following to php.ini.

This command will show you which php.ini file is used by MAMP php

/Applications/MAMP/bin/php/php7.4.1/bin/php -i | grep "php.ini"

Add extension=gmp.so

Restart MAMP :)

Posted here with screenshots, https://mycodde.blogspot.com/2020/01/install-php-gmp-extension-in-mamp-2020.html

Installing GMP extention on PHP 7.4 FPM Aplpine (Docker)

Like the error says: configure: error: GNU MP Library version 4.2 or greater required.

You can install GNU MP (GMP for short) on Alpine Linux by including the following in your Dockerfile:

RUN apk add gmp-dev

(or RUN apt-get install gmp-dev for other debian distros)

Trying to install the GMP extension on Docker / php:5.3

I was able to do it thusly:

FROM php:5.3

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010 AA8E81B4331F7F50 9D6D8F6BC857C906 \
&& apt-get update \
&& apt-get install -y libgmp-dev wget \
&& ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h \
&& cd /tmp \
&& wget --no-check-certificate https://museum.php.net/php5/php-5.3.29.tar.xz \
&& tar xvf php-5.3.29.tar.xz \
&& cd php-5.3.29/ext/gmp \
&& phpize \
&& ./configure \
&& make \
&& make install \
&& echo extension=gmp.so > /usr/local/lib/php.ini

Installation of php5-gmp on Ubuntu 16.04

Try php5.6-gmp:

sudo apt install php5.6-gmp

Obvously this will only install gmp extension for PHP5.6.
If you want it to 7.0, use the right package name:

sudo apt install php7.0-gmp


Related Topics



Leave a reply



Submit