Installing custom PHP with GMP

Installing custom PHP with GMP

Posted by: pfctdayelise
Posted on: 2007-04-13 05:20:00

Hello,

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

I used the script here http://wiki.dreamhost.com/Installing_PHP5 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. :/

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

thanks in advance!

Re: Installing custom PHP with GMP

Posted by: Mousee
Posted on: 2007-04-13 05:56:00

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

Re: Installing custom PHP with GMP

Posted by: pfctdayelise
Posted on: 2007-04-13 06:02:00

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

==================
#!/bin/sh

# 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
# filesystem.
# ***Don't pick a directory that already exists!*** We clean up after
# ourselves at the end!
SRCDIR=${HOME}/source

# And where should it be installed?
INSTALLDIR=${HOME}/php5

# Set DISTDIR to somewhere persistent, if you plan to muck around with this
# script and run it several times!
DISTDIR=${HOME}/dist

# Pre-download clean up!!!!
rm -fr $SRCDIR $DISTDIR

# Update version information here.
PHP5="php-5.2.0"
GMP="gmp-4.2.1"

# What PHP features do you want enabled?
PHPFEATURES="--prefix=${INSTALLDIR}
--with-gmp"

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

# Push the install dir's bin directory into the path
export PATH=${INSTALLDIR}/bin:$PATH

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

# Get all the required packages
wget -c http://us3.php.net/distributions/${PHP5}.tar.gz
wget -c http://ftp.sunet.se/pub/gnu/gmp/${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.

# gmp
cd ${SRCDIR}/${GMP}
./configure --prefix=${INSTALLDIR}
# make clean
make
make install

#PHP 5
cd ${SRCDIR}/${PHP5}
./configure ${PHPFEATURES}
# make clean
make
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
rm -fr $SRCDIR $DISTDIR
echo ---------- INSTALL COMPLETE! ----------

Re: Installing custom PHP with GMP

Posted by: Mousee
Posted on: 2007-04-13 06:27:00

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:

In reply to:


./configure --help


(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

In reply to:


--libdir=/home/username/lib


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

In reply to:


LDFLAGS="-L/home/username/lib" ./configure --prefix=/home/username/php5 --other=options-here


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

Re: Installing custom PHP with GMP

Posted by: pfctdayelise
Posted on: 2007-04-15 04:07:00

aha, you are awesome! thanks so much!

Re: Installing custom PHP with GMP

Posted by: Mousee
Posted on: 2007-04-15 05:16:00

No problems wink

Tags: dreamhostwikiphp5thanks in advance