This gist assumes that you've followed these instructions to set up your AMP on OS X, and that you're using php-version to change PHP versions as needed.
Note that I have selected the wrong tool for the job with php-version. However once I got this working I wanted to document it in case I want to replicate the config without selecting a more appropriate tool. If you stumble upon this gist and decide to find a better tool for the job I'd appreciate a comment directing myself and others to something better.
Now if you're sure you want to drive a square peg into a round hole, continue reading...
First, modify php-version to run a post version change script when php versions are changed.
$ vi $(brew --prefix php-version)/php-version.sh
Near the bottom of this file, just above hash -r
add:
if [[ -x $HOME/.php-version ]]; then
~/.php-version
fi
Now create .php-version in your home directory with the following contents:
MAJOR_VERSION=`php-config --version | cut -d\. -f1`
PREFIX=`php-config --prefix`
cat > $HOME/Sites/php-version.conf <<EOF
LoadModule php5_module ${PREFIX}/libexec/apache2/libphp${MAJOR_VERSION}.so
EOF
Make this file executable:
$ chmod +x ~/.php-version
Modify your httpd.conf (tweak this path if your apache version is different):
$ vi $(brew --prefix)/etc/apache2/2.2/httpd.conf
Find the LoadModule for PHP, remove it and replace it with:
Include /Users/YOUR_USER_NAME/Sites/php-version.conf
Remembering to replace YOUR_USER_NAME
with your user name.