Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Builds a LAMP (MAMP) stack on macOS 12.5.1 Monterey using MacPorts.

Intended to be used on a fresh macOS install.

The main branch supports MySQL 5.7.

The mariadb55 branch supports MariaDB 5.5.

For versions of macOS before 10.13 use the pre-high-sierra branch.

Please read this README all the way through before beginning.


MacPorts is powerful but finicky. I commonly end up with MySQL with the wrong permissions and other annoyances. Therefore this script, which will reliably install MariaDB 5.7 and PHP 7.3/7.4/8.1 plus Apache 2.4 on macOS. At least, for me. Tested with MacPorts 2.7.2 on OS X 12.5.1.


If you had installed macports-lamp previously, export any MySQL databases you want to keep (since macports-lamp will install a clean 'n' fresh MySQL).

Stop any running MacPorts services as in the following two examples. If these give you errors, just continue.

sudo port unload apache2
sudo port unload mariadb-server

Move/rename /Applications/MacPorts.

Move the old MacPorts installation in /opt out of the way. If you have System Integrity Protection enabled, you may need to disable it first.

sudo mv /opt/local /opt/local.old

Install MacPorts with its prerequisites.

Make sure to install XCode and do

sudo xcodebuild -license
xcode-select --install

macports-lamp comes with a my.cnf file for MySQL 5.7 that it will place at /etc/my.cnf. If you already had a my.cnf there it will be moved out of the way.

MySQL 5.7 will use the following socket:

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

Default Virtual Host

The script will create the following virtual host which can be reached by going to http://local.test/ after the script completes.

<VirtualHost *:80>
    ServerName local.test
    DocumentRoot /Users/username/Sites
    <Directory /Users/username/Sites>
      Options Indexes FollowSymLinks
      DirectoryIndex index.php index.html
      Require local
      AllowOverride All
<VirtualHost *:443>
    ServerName local.test
    ServerAlias *.local.test
    DocumentRoot /Users/username/Sites
    <Directory /Users/username/Sites>
      Options Indexes FollowSymLinks
      DirectoryIndex index.php index.html
      Require local
      AllowOverride All


The following functions will be installed in ~/.bash_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 (really sudo port unload apache2;sudo port load apache2)

Running the Scripts

sudo ./build_lamp
sudo ./build_ssl_cert
sudo ./build_mysql
sudo ./increase_limits

Switching between PHP 7.3, PHP 7.4 and PHP 8.1:

Switch to PHP 8.1:

sudo port select php php81
sudo /opt/local/bin/apxs -A -e -n php7
sudo /opt/local/bin/apxs -A -e -n php7
sudo /opt/local/bin/apxs -a -e -n php

Switch to PHP 7.4:

sudo port select php php74
sudo /opt/local/bin/apxs -A -e -n php
sudo /opt/local/bin/apxs -A -e -n php7
sudo /opt/local/bin/apxs -a -e -n php7

Switch to PHP 7.3:

sudo port select php php73
sudo /opt/local/bin/apxs -A -e -n php
sudo /opt/local/bin/apxs -A -e -n php7
sudo /opt/local/bin/apxs -a -e -n php7

If you disabled System Integrity Protection earlier, don't forget to reenable it. You can check if it is enabled by typing csrutil status in Terminal.


If the MySQL installation messed up somehow, and you want to try it again, use the following to clean up and retry:

sudo port unload mysql57-server
sudo port uninstall mysql57-server
sudo rm -rf /opt/local/var/db/mysql57/
sudo ./build_mysql 


To install Drush, see



Builds a LAMP stack on macOS X using MacPorts







No releases published


No packages published