Installing PHP on Mac OS X

I’m back from my surgery. Thankfully, the laptop from my new employer arrived just in time to keep me occupied during recovery. It’s a 17″ MacBook Pro with the 1920×1200 resolution screen (Sah-weet!). 4 GB of RAM. I must say, this is probably the only machine that could have EVER switched me to being a Mac user. I will write a comprehensive review of what (still) bothers the hell out of me (after two weeks of use) in OS X, and what I find really cool (hint: the Unix prompt is #1). Anyway, I digress…

I just had the pleasure of installing PHP on Mac OS X. It took me about 3 hours to compile PHP 5.2.4 with MySQL, GD, and XML DOM API. By 3 hours, I mean, to find all the libraries, download them, compile them and install. I know OS X ships with PHP 4, but c’mon — PHP 4 will be discontinued by the end of the year.

I had to build it all from source. It was the only way to get those options. There are no pre-compiled binaries for OS X.

I will not go through all the steps. I will only point out the problems that I’ve had with the installation (of which there weren’t many).

Mainly, I followed Apple Developer Connection and GD [libgd.org] installation instructions.

To install PHP, you obviously need the PHP library, MySQL, and GD. GD also requires
– zlib
– libpng
– libjpeg
– freetype2

(outlined in the link above)

The one error message I received was “dyld: Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib” when running ‘make install’ for PHP.

I found a “dirty” fix at MySQL Forums. Run:


cd /usr/local/mysql/lib
mkdir mysql
cp libmysqlclient.15.dylib mysql/libmysqlclient.15.dylib

Next up: making Eclipse use the PHP parser to debug my scripts (first time ever doing this!)
Also: Using Smarty to separate function from form.

[Edit]: For some really strange reason, I cannot get symbolic links to work in user directories in OS X’s apache server (version 1.3??). In any case, I had to settle for writing symbolic links to the freaking document root directory, conveniently located (outside any Unix or Linux conventions) in /Library/Webserver/Documents/. Yes, I tried editing the httpd.conf file, I looked at file permissions, but everything looks fine. I spent about 2 more hours on this, before I lost my mind. With that, I go to sleep… (damn you FollowSymLinks, damn you!!!!!!)

Leave a Reply