Builds a LAMP stack on OS X 10.9 or 10.10 using MacPorts
Latest commit 803d9a4 Dec 17, 2016 @clouseau Update for OS X 10.11
Failed to load latest commit information.


Builds a LAMP (MAMP) stack on OS X 10.11 El Capitan using MacPorts.

Intended to be used on a fresh 10.11 install.

Please read this README all the way through before beginning.


MacPorts is powerful but finicky. I commonly end up with MySQL (I know, we're all switching to MariaDB soon) with the wrong permissions and other little niggling trouble. Therefore this script, which will reliably install MySQL 5.5 and PHP 5.6 plus Apache 2.2 on OS X. At least, for me. Tested with MacPorts 2.3.5 on OS X 10.11.


Install MacPorts with its prerequisites.

Make sure to install XCode and do

sudo xcodebuild -license
xcode-select --install

Create a my.cnf and put it at /etc/my.cnf. You could use the Percona Wizard.

Ensure that /etc/my.cnf has a line for the socket MacPorts will use:

socket      = /opt/local/var/run/mysql55/mysqld.sock

Read Through the Script

Note that it will set your MySQL root password to "password" unless you change this in the expect heredoc (ca. lines 36, 39).

Default Virtual Host

The script will create the following virtual host which can be reached by going to after the script completes.

NameVirtualHost *:80
<VirtualHost *:80>
    DocumentRoot /Users/username/Sites
    <Directory /Users/username/Sites>
      Options Indexes FollowSymLinks
      DirectoryIndex index.php index.html
      Order deny,allow
      Allow from
      AllowOverride All


The following functions will be installed in ~/.profile. I find them useful at the command line:

te - tail Apache error log
ta - tail Apache access log
tp - tail PHP error log
acr - apachectl restart

Running the Scripts

sudo ./build_lamp
sudo ./build_mysql


The install_drush script is now a historical footnote and should not be used.