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 !
- No related posts
March 5th, 2006 at 9:41 pm
Hey Richard,
try running ‘make test’ after the ‘make install’. It will run PHP’s test suite testing (mostly) everything you enabled with configure.
With your configure line it might take a little while, though.
Keep it up!
Jan
–
Richard5: Thanks Jan, I’ve tried it and most of the items pass. I didn’t know this tested all the libraries as well, thanks for the great tip !
March 6th, 2006 at 2:48 am
Richard, when the .configure process gets to this point, I receive:
Configuring extensions
checking for OpenSSL support… yes
checking for Kerberos support… no
checking for pkg-config… no
configure: error: Cannot find OpenSSL’s libraries
any ideas?
Thanks!
March 8th, 2006 at 10:06 pm
Richard,
You might also want to take a look at Marc Liyanage’s pages http://www.entropy.ch/software/macosx/php/. I think he’s tied to Server Logistics somehow, but he has PHP5 and PHP4 versions for both Apache1 and Apache2. The only thing I don’t know is if he has it configured for as many modules as Server Logistics.
–Markis
March 17th, 2006 at 8:31 am
Great work, Richard. Thanks!
I did also run into:
Configuring extensions
checking for OpenSSL support… yes
checking for Kerberos support… no
checking for pkg-config… no
configure: error: Cannot find OpenSSL’s libraries
Don’t know what the deal is…
August 6th, 2006 at 7:45 am
Hi,
Like others, great to see this on the net. I’m trying to get PHP 4.4.2, Apache 1.3 and MySQL 4.0.27 running on a new macbook pro.
Using xcode 2.3, everything is compiled, except for php. Following your instructions I get an unknown link error for -export-symbols.
Removing the flag, generates a huge about of errors. Any ideas ?
-Ben-
September 2nd, 2006 at 6:36 pm
Hi,
Good job! Richard. Thanks!
>configure: error: Cannot find OpenSSL’s libraries
Does not “Fink” move?
It went well for me when “Fink” was uninstalled.