Skip to content

Instantly share code, notes, and snippets.

@tomhapbia
Forked from rasmuscnielsen/mamp-php-gmp.md
Created March 22, 2024 10:08
Show Gist options
  • Save tomhapbia/51d3d8aa2c1a5c1d1c050109ca4c01dd to your computer and use it in GitHub Desktop.
Save tomhapbia/51d3d8aa2c1a5c1d1c050109ca4c01dd 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.

@tomhapbia
Copy link
Author

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

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

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