What is this? From this page you can use the Social Web links to save Compiling PHP 4.4.2 on the Mac to a social bookmarking site, or the E-mail form to send a link via e-mail.

Social Web

E-mail

E-mail It
March 05, 2006

Compiling PHP 4.4.2 on the Mac

Posted in: PHP

Server Logistics has a great package for installing the (L/M)AMP applications stack on Mac OS X, the only drawback is that they don’t upgrade their packages as I would like to see it happen. Especially when there are security issues with older version of PHP, MySQL or Apache. I’ve been able to get a more recent version of Apache compiled then they released and the last few days I’ve been struggling to get PHP compiled. I wanted to recompile PHP4 and PHP5 to be able to provide some choices. I’ve successfully compiled PHP4 and kept most of the Server Logistics structure intact. Most of the credits go to Bjarne D Mathiesen who wrote some documents and scripts in Danish I used to get this working.
The only thing I had to disable to get it compile was the support for SNMP, it is something I guess not many need so I just removed it from the list of options to include.

Get the source for PHP 4.4.2 from www.php.net and extract the archive into a separate directory. When that’s done open a Terminal window and go to the directory you extracted the archive in. You now need to change the configure script with the following commands:

sed 's/\(LIBS="\)\(-lpspell \$LIBS"\)/\1-laspell \2/' configure > configure.1
mv configure.1 configure
chmod a+x configure

This makes some changes to which library gets used during compilation. Now you are ready to run the configure script. Please feel free to remove options you don’t see any need for, I tried to get everything in there that Server Logistics provided in their package.

./configure \
--prefix=/Library/PHP4 \ --enable-shared \
--with-apxs2=/Library/Apache2/bin/apxs \
--disable-cgi \
--enable-magic-quotes \
--disable-short-tags \
--with-openssl=/usr \
--with-zlib-dir=/usr \
--enable-calendar \
--enable-exif \
--enable-ftp \
--enable-mbstring \
--enable-sockets \
--enable-wddx \
--enable-yp \
--enable-trans-id \
--enable-track-vars \
--with-mysql=/Library/MySQL \
--with-ldap=/usr \
--with-iodbc=/Library/PHP4 \
--with-gettext=/Library/PHP4 \
--with-gd \
--with-jpeg-dir=/Library/PHP4 \
--with-png-dir=/Library/PHP4 \
--with-tiff-dir=/Library/PHP4 \
--enable-gd-native-ttf \
--with-ttf=/Library/PHP4 \
--with-freetype-dir=/Library/PHP4 \
--with-t1lib=/Library/PHP4 \
--without-xpm-dir \
--with-pdflib=/Library/PHP4 \
--with-mcrypt=/Library/PHP4 \
--with-curl=/usr \
--with-iconv=/usr \
--enable-mime-magic \
--with-pspell=/Library/PHP4 \
--with-expat-dir=/Library/Apache2 \
--enable-xslt \
--with-xslt-sablot=/Library/PHP4 \
--with-xmlrpc \
--with-dom=/Library/PHP4 \
--with-dom-xslt=/Library/PHP4 \
--with-dom-exslt=/Library/PHP4 \
--enable-dbx \
--with-imap=/Library/PHP4 \
--with-imap-ssl=/usr \
--enable-dbase \
--with-bz2=/usr \
--with-java \
--enable-ucd-snmp-hack \
--with-mhash=/Library/PHP4 \
--with-ming=/Library/PHP4 \
--enable-shmop \
--with-gmp=/Library/PHP4 \
--enable-dio \
--enable-bcmath \
--enable-dba \
--with-cdb

This will take some time to complete. When it’s finished you need to change the Makefile with the following command:

sed '/INCLUDES/s/^\(.*\)\( -I\/Library\/PHP4\/include \)\(.*\)$/\1 \3 \2/' Makefile > Makefile.1
mv Makefile.1 Makefile

This changes the order inwhich the include files are scanned to prevent compiler errors with the Freetype 1 and 2 include files.

Now you are ready to run the make command. Please go and make some coffee as this will run for a long time…

When the compilation is finished you can install the new PHP4 version by running:

sudo make install

When this is finished you need to restart Apache2 to activate the new version of PHP4.

I haven’t found a simple way to test all the included options I just ran phpinfo() to see if everything was included. If you know of a script to test all the options please let me know and I’ll test it out and include it with this blog entry for others to benefit.

Please note that you should already have the original PHP4 package from Server Logistics installed or this won’t work !


Return to: Compiling PHP 4.4.2 on the Mac