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.
--prefix=/Library/PHP4 \ --enable-shared \
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