Skip to content

Instantly share code, notes, and snippets.

@rasmuscnielsen
Forked from wimarbueno/mamp-php-gmp.md
Last active May 22, 2024 12:20
Show Gist options
  • Save rasmuscnielsen/8b95edaab6e1fe20cd9ef427d3ae23c6 to your computer and use it in GitHub Desktop.
Save rasmuscnielsen/8b95edaab6e1fe20cd9ef427d3ae23c6 to your computer and use it in GitHub Desktop.
How to install GMP extension for PHP 7.4.2 using MAMP

Installing GMP extension for PHP 7.4 using MAMP

You have to build the GMP extension from the PHP source code. First install Autoconf and GMP using Homebrew.

brew install autoconf gmp

Download and unpack PHP.

http://php.net/get/php-7.4.2.tar.bz2/from/a/mirror

$ cd php-7.4.2/ext/gmp
$ /Applications/MAMP/bin/php/php7.4.2/bin/phpize
$ ./configure --with-php-config=/Applications/MAMP/bin/php/php7.4.2/bin/php-config
$ make
$ make install

Add the extension loading config to php.ini in /Applications/MAMP/bin/php/php7.4.2/conf.

extension=gmp.so

Restart MAMP servers and verify extension is loaded in the phpinfo() report.

@failamir
Copy link

failamir commented Oct 8, 2022

it works, thanks bro

@Stichoza
Copy link

Have you tried same for PHP >= 8.2.0? I'm getting the error "GNU MP Library version 4.2 or greater required".

I have tried this but it didn't help.

@syaikhipin
Copy link

Hi @Stichoza , I have tried to compile with this stuff (mac m1) : ./configure --with-php-config=/Applications/MAMP/bin/php/php8.1.13/bin/php-config CXXFLAGS="-I/opt/homebrew/Cellar/gmp/6.2.1_1/include" CPPFLAGS="-I/opt/homebrew/Cellar/gmp/6.2.1_1/include" LDFLAGS="-L/opt/homebrew/Cellar/gmp/6.2.1_1/lib"

@tomhapbia
Copy link

tomhapbia commented Mar 22, 2024

Have you tried same for PHP >= 8.2.0? I'm getting the error "GNU MP Library version 4.2 or greater required".

I have tried this but it didn't help.
I got the same error on Mac M1 and i have fixed.
You can try this:

export CPPFLAGS="-I/opt/homebrew/Cellar/gmp/6.3.0/include"
export LDFLAGS="-L/opt/homebrew/Cellar/gmp/6.3.0/lib"
export CXXFLAGS="-I/opt/homebrew/Cellar/gmp/6.3.0/include"
./configure --with-php-config=/Applications/MAMP/bin/php/php7.4.33/bin/php-config

Replace gmp version in brew location and php version.

Ref: https://stackoverflow.com/a/68379616

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment