If you are using macports, you can easily install the package of “php-gmp”.
But if you are a user of homebrew like me, you may need these tips.
First, you have to install gmp via homebrew, but it will give you gmp 5.0.1, which doesn’t work with PHP 5.3
So you have to modify your Formula, go to /usr/local/Library/Formula/gmp.rb and modify:
url 'ftp://ftp.gnu.org/gnu/gmp/gmp-5.0.1.tar.bz2'
sha1 '6340edc7ceb95f9015a758c7c0d196eb0f441d49'
to
url 'ftp://ftp.gmplib.org/pub/gmp-4.3.2/gmp-4.3.2.tar.bz2'
sha1 'c011e8feaf1bb89158bd55eaabd7ef8fdd101a2c'
Now, you can run
brew install gmp
to install gmp.
Next step, download the php source code from php.net, we will need to build a php_gmp.so module from it.
Extract the source code and go to phpsource/ext/gmp/
run
phpize
./configure
MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64' make -j6;sudo make install
And you will get your gmp.so in phpsource/ext/gmp/module/
Copy that to your /usr/lib/php/extensions/no-debug-non-zts-20090626/
And load it in your /private/etc/php.ini
It’s done!