Compiling PHP 5.1.2 on the Mac
Posted in: PHP
Well I’ve got it working, it took some time because there was an older library in the PHP4 directory structure from Server Logistics that didn’t like PHP5 ! The XML library needed an upgrade to be included into PHP5 so I first had to solve that issue to get it all working. The only library I had to exclude was SNMP for the same reason as I had to leave it out from the PHP 4.4.2 compilation. The rest of the libraries that are used from the original PHP4 installation from Server Logistics so please install that before you try this upgrade.
First you need to download the sourcecode for the new libxml2 library, you can get it from the GNOME ftp server. I’ve downloaded and used the latest version which was at this time version 2.6.23.
Extract the archive into a directory and run the following commands in a Terminal
make as we’ve done so many times already. When it is finished compiling you can install the library by running
sudo make install and when that is done you’ll have to create a copy of the library in the directory
/Library/PHP5/lib/ which you can do with the command
sudo cp /usr/local/lib/libxml184.108.40.206.dylib /Library/PHP5/lib
When this is done you can start downloading from www.php.net. Extract the source archive into a directory and use the Terminal to execute 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 just like the PHP4 script. 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.
If this ends then
sed '/INCLUDES/s/^\(.*\)\( -I\/Library\/PHP4\/include \)\(.*\)$/\1 \3 \2/' Makefile > Makefile.1
mv Makefile.1 Makefile
When ready you can try to compile, you’ll be getting a lot of warnings and it will take a while. Compile by issuing the command:
When you are ready and made proper backups of your production environment you can issue the install command:
sudo make install
This updates your httpd.conf file as well by adding the entries PHP5, but it doesn’t remove any entries for PHP4. You’ll have to remove them yourself and restart Apache.
Please note that there isn’t a php.ini file in the configured directory
/Library/PHP5/lib. You can copy one from the source directory or the one from your PHP4 installation.
Return to: Compiling PHP 5.1.2 on the Mac