Making Leopard PHP a better PHP by adding GD support
Command Line Tricks, MacOS X Annoyances March 4th. 2008, 7:32pmThe nice thing about MacOS X 10.5 Leopard is that it comes with PHP 5.2.4 pre-installed. Unfortunately one of the features Apple choose not to compile in was support for the GD graphics library, which I use extensively. Furthermore compiling in new features has proven to be somewhat troublesome. When I tried to configure PHP 5.2.5 on my Leopard box which the following commands (a variant of the configure command I would issue under Tiger with no complaints):
The result was a failed configure due to an error in mysql configuration. I pinned this down to a request for a library at<br />./configure --prefix=/usr --mandir=/usr/share/man <br /> --infodir=/usr/share/info --disable-dependency-tracking <br /> --with-apxs2=/usr/sbin/apxs <br /> --with-ldap=/usr --with-kerberos=/usr <br /> --enable-cli <br /> --with-zlib-dir=/usr <br /> --enable-trans-sid <br /> --with-xml <br /> --with-dom <br /> --enable-exif <br /> --enable-ftp <br /> --enable-mbstring <br /> --enable-mbregex <br /> --enable-dbx <br /> --enable-sockets <br /> --with-iodbc=/usr <br /> --with-curl=/usr <br /> --with-iconv=shared,/opt/local<br /> --with-openssl=shared,/opt/local <br /> --with-xmlrpc <br /> --with-xsl=/usr <br /> --with-config-file-path=/etc <br /> --sysconfdir=/private/etc <br /> --with-gd=/opt/local --enable-gd-native-ttf <br /> --with-jpeg-dir=/opt/local <br /> --with-tiff-dir=/opt/local <br /> --with-png-dir=/opt/local <br /> --with-freetype-dir=/usr/X11 <br /> --with-xpm-dir=/usr/X11 <br /> --with-pdflib=/opt/local <br /> --with-gettext=/opt/local<br /> --with-mysql=/usr/local/mysql <br /> --with-mysqli=/usr/local/mysql/bin/mysql_config <br /> --with-pdo-mysql=/usr/local/mysql <br /> --without-pear<br />
/usr/local/mysql/lib/mysql/libmysqlclient.15.dylib which is actually located one directory up. This can be fixed via the command line using:
Then the<br />cd /usr/local/mysql/lib<br />mkdir mysql<br />cp libmysqlclient.15.dylib mysql/libmysqlclient.15.dylib
./configure worked just fine. Unfortunately, when I did a
to compile the PHP and test it, there was no happiness. There were over 50 errors, some of them major. Crud.<br />make<br />make test
This is just the setup. See, all I needed was GD graphics library support in PHP for my website. Well, after googling for some time for some master hacker’s notes on getting PHP 5.2.5 to compile on Leopard, I discovered a fellow named Hill Pei had hacked GD support into the Leopard PHP without too much effort. His method simply requires some comfort with the command line and editing text files. In five minutes, I had GD support with Leopard’s built-in PHP. Excellent! [Despite a report in the comments to the contrary. This still appears to be necessary if you apply Security Update 2008-002, which installs PHP version 5.2.5. In which case, you should grab the php 5.2.5 code and work from there. I can confirm Hill Pei's instructions do work after Security Update 20008-002 if you grab the PHP-5.2.5 code instead of 5.2.4 as he suggests.]









March 13th, 2008 at 12:12 am
Hey there
great post … a question for you. how did you update PHP on leopard from 5.2.4 to 5.2.5?? Is it easy enough to do? A step by step tutorial would be awesome if you had the time. It seems the 5.2.4 that comes with Leopard is also missing things like mcrypt & pdo_mysql
March 13th, 2008 at 5:27 pm
Unfortunately, I have been unable to get PHP 5.2.5 to compile properly in Leopard, despite trying some tricks like re-installing/upgrading Apache and the like. PHP 5.2.5 just throws a slew of errors in its ‘make test’ phase when I attempt to get it working, so I have given up on upgrading to it for now.
March 21st, 2008 at 12:38 am
It looks to me like Apple’s recent security update (2008-002), which updates PHP to 5.2.5, has bundled GD support into the PHP apache module.
That’s good news, except for one small detail: the CLI version of PHP 5.2.5 that they’ve provided does NOT appear to include GD support. So when I run any PHP tests using the command-line interface, I still have to use a home-built version of PHP.
Also, I suspect the reason many people have been unsuccessful building their own PHP for Leopard is because Leopard needs a 64-bit version of PHP — in part because the OS shipped with a 64-bit version of apache.
I recommend building just the GD library, rather than all of PHP, and continue using the pre-installed PHP. Before the 2008-002, I was able to do that as follows:
I haven’t tried this procedure again with the 5.2.5 PHP sources and 2008-002 security update, however.
March 24th, 2008 at 6:36 pm
Fyi, the above steps do still work with 2008-002 and PHP 5.2.5.
Also, I remembered those steps came from: osx.topicdesk.com
April 10th, 2008 at 4:33 pm
[...] did indeed install osxutils as promised. I also noticed they upgraded from version 1.6 to 1.7, maybe that was all that was necessary. All the MacPorts packages I used in Tiger now work in Leopard. Now if I could only get a proper recompile of PHP working under Leopard. [...]