UPDATED: Install PHP 5.2 stack from source on Mac OS X 10.6 Snow Leopard using Homebrew
I've updated the instructions to build a nice clean and fast PHP 5.2 stack using my own build scripts and the homebrew build system.
All software is installed into /usr/local for easy management and while it works with the included OS X Apache and libraries where possible it is installed in such a way that system updates from Apple don't clobber anything.
I use this stack as my local PHP and Drupal development environment.
The instructions are rather verbose but if you don't really care how it's done I've included a build script below that will do everything except the final configuration work.
NOTE: You require the Apple Development tools (XCode, etc.) installed to build software from source.
To run this quick install script, launch Terminal.app, copy the following block of code and paste into the terminal to create the script:
cat <<EOF > install-php52.sh
#!/bin/bash
if [ -d /usr/local ]; then
echo "moving existing /usr/local to /Users/`whoami`/local.bak"
sudo mv /usr/local ~/local.bak
fi
sudo mkdir /usr/local && sudo chown -R `whoami` /usr/local
curl -L http://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C /usr/local
brew install git
cd /usr/local
git init
git remote add origin git://github.com/mxcl/homebrew.git
git pull origin master
git remote add boztek git://github.com/boztek/homebrew.git && git fetch boztek
git checkout boztek/php52 && git checkout -b working
git pull --rebase origin master
brew install php52 --with-mysql --with-apache
EOF
Then to run the script copy and paste this line:
chmod u+x ./install-php52.sh && ./install-php52.sh
Ain't git grand?