Installing custom PHP with GMP


I have had trouble trying to install my own PHP with the GMP library.

I used the script here and added the various bits for GMP. But it would always die:

Configuring extensions
checking for GNU gettext support… no
checking for GNU MP support… yes
configure: error: Unable to locate gmp.h

According to Dreamhost support, it’s not the process watcher killing it off, and… here I am. :confused:

Any ideas?? I can post the script if that’s useful.

thanks in advance!

It’s really quite simple actually, and that error explains it all.
You need to have the GNU MP library (GMP) installed before you can install support for it in PHP. Apparently DH’s servers do not have GMP installed by default, so you’d have to compile it into your user environment first.

Hopefully that helps :wink:

Here is the script I was using. (I cut out everything except GMP and PHP.) Is it not attempting to install GMP first?


Save the code to a file as *.sh

Abort on any errors

set -e

The domain in which to install the PHP CGI script.

export DOMAIN=…

Where do you want all this stuff built? I’d recommend picking a local


Don’t pick a directory that already exists! We clean up after

ourselves at the end!


And where should it be installed?


Set DISTDIR to somewhere persistent, if you plan to muck around with this

script and run it several times!


Pre-download clean up!!!


Update version information here.


What PHP features do you want enabled?


---- end of user-editable bits. Hopefully! ----

Push the install dir’s bin directory into the path


#setup directories
mkdir -p ${SRCDIR}
mkdir -p ${INSTALLDIR}
mkdir -p ${DISTDIR}

Get all the required packages

wget -c${PHP5}.tar.gz
wget -c${GMP}.tar.gz

echo ---------- Unpacking downloaded archives. This process may take
several minutes! ----------

cd ${SRCDIR}

Unpack them all

echo Extracting ${PHP5}…
tar xzf ${DISTDIR}/${PHP5}.tar.gz
echo Done.
echo Extracting ${GMP}…
tar xzf ${DISTDIR}/${GMP}.tar.gz
echo Done.

Build them in the required order to satisfy dependencies.


cd ${SRCDIR}/${GMP}
./configure --prefix=${INSTALLDIR}

make clean

make install

#PHP 5
cd ${SRCDIR}/${PHP5}
./configure ${PHPFEATURES}

make clean

make install

#copy config file
mkdir -p ${INSTALLDIR}/etc/php5/${DOMAIN}
cp ${SRCDIR}/${PHP5}/php.ini-dist ${INSTALLDIR}/etc/php5/${DOMAIN}/php.ini

#copy PHP CGI
mkdir -p ${HOME}/${DOMAIN}/cgi-bin
chmod 0755 ${HOME}/${DOMAIN}/cgi-bin
cp ${INSTALLDIR}/bin/php ${HOME}/${DOMAIN}/cgi-bin/php.cgi
echo ---------- INSTALL COMPLETE! ----------

Ah, well indeed you are installing GMP, but you have to inform PHP of it’s install location as well.
You can check for all the specific config options by running:

(after you unpack the gmp source that is)

But specifically, you’ll need to either point gmp to the same library location that PHP will be using, or let PHP know where this is when you got to configure it.
For instance, let’s say I installed GMP’s libraries, using the

option. You’d let PHP know the location of GMP’s libraries then by specifying something like this:

This in essence tells PHP where to look for GMP’s libraries.

aha, you are awesome! thanks so much!

No problems :wink:

Just an FYI for future visitors since this comes up top-of-Google for “gmp DreamHost”, the shared hosts now include gmp. All I needed to do was add “extension =” to my phprc file.

See for those instructions.