This guide shows how to roll PHP and MySQL using OSX's built-in Apache, using Homebrew to install necessary components. Using this strategy, you can use different versions of PHP for certain virtual hosts.
I use VirtualHostX as a convenient way to manage all of my development sites, but it's not required.
brew update
brew install php56
brew install php56-mcrypt
brew install mysql
mysql.server start
The mcrypt extension is required for some PHP frameworks such as Laravel.
Optional: Install other extensions or versions of PHP
brew install php56-xdebug
brew install php55
brew install php55-mcrypt
Test PHP:
/usr/local/Cellar/php56/5.6.0/bin/php --version
This should yield PHP 5.6.0 (cli).
Edit your ~/.bash_profile by adding the line:
alias php='/usr/local/Cellar/php56/5.6.0/bin/php'
Test your PHP alias:
php --version
This should again yield PHP 5.6.0 (cli).
Configure VirtualHostX to use Built-in Apache instead of MAMP.
Create a new site with custom virtual host directives:
LoadModule php5_module /usr/local/Cellar/php56/5.6.0/libexec/apache2/libphp5.so
AddType application/x-httpd-php .php
DirectoryIndex index.html index.htm index.php
You can achieve the above without VirtualHostX by manually editing:
/private/etc/hosts
/private/etc/apache2/httpd.conf
/private/etc/apache2/extra/httpd-vhosts.conf
With a MySQL client such as Sequel Pro, connect to MySQL at localhost with the username root and no password. Change the password if you like.