Call + (44) 0843 289 4539

Setting PHP7 Development on mac osx

This tutorial will guide you through the process of setting up Mac OSX (El Capitan) for PHP 7 software development. We internally call this the Poor Man’s MAMP, as it uses all free open source tools to effectively re-create all the functionality you get using MAMP, only a little less restrictive.

In order to follow along with the tutorial you will need to ensure you install HomeBrew on your mac

** Update : We have now completely Automated this process of setting up the Environment and you can now use a simple BASH script

The script is available from our GitHub repository


We will use HomeBrew to install PHP. We will go ahead and install all versions of PHP, but will leave PHP7 active.

$ brew tap homebrew/dupes
$ brew tap homebrew/versions
$ brew tap homebrew/homebrew-php
$ brew install php54
$ brew unlink php54
$ brew install php55
$ brew unlink php55
$ brew install php56
$ brew unlink php56
$ brew install php70


This is a great little tool to that allows us to use wildcard subdomain names.

With the default apache settings, you can add as many sites as you like in subfolders of the web root. Using dnsmasq we’ll create domains like

brew install dnsmasq
cd $(brew --prefix)
mkdir etc
echo 'address=/.dev/' > etc/dnsmasq.conf
sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
sudo mkdir /etc/resolver
sudo bash -c 'echo "nameserver" > /etc/resolver/dev'


Mac OSX already comes shipped with the Apache Web server installed. However, we are going to need to configure it exactly for our needs.

The default setting for Apache is serve all files from


We are going to change this, primarily because we will want the ability to edit and create multiple development websites on our local machine.

Create a folder in your Home folder called Sites. You can do this by either making use of the terminal as below, or simply creating new folder in GUI.

$ mkdir Sites

We will go ahead and create two files in this new directory for now. We will be using them to test our configuration.

$ cd Sites
$ touch index.htm
$ touch info.php

We just add some content to the files now. We’ll use nano for this but you can go ahead and use any other text editor

$ cd Sites
$ nano index.htm

Add the following content and the CTRL + X to exit and save

<html><body><h1>Test Website</h1></body></html>

Create a php info page

$ cd Sites
$ nano info.php

Add the following content and the CTRL + X to exit and save

<?php phpinfo(); ?>

There will be a number of changes required to a few Apache configuration files.   Instead of walking through change by change,  you can download the files and see for yourselves. Apache2 Configuration Files .

After making some additional edits to the files to ensure they will work on you environment you can copy them to you apache2 folder. Which you can by using Go -> Go to Folder on Finder . The typing /private/etc/apache2


I have created a simple BASH script to create the folders and edit the Apache config files required.


We are constantly evolving this project as we go through it regularly on-boarding new developers so check out out GitHub repository and the detailed instructions on how to use it.

All that is required for the script to work is extract to your Root folder and execute.  The script will create the necessary root folder with whatever name you supply, and required sub folders. It will also edit the necessary apache2 config files, enabling you to copy and paste them to /private/etc



Installing mySQL is really easy using HomeBrew.

$ brew install mysql

Start your MySQL server

$ brew services start mysql

Don’t forget to secure your mysql installation

$ mysql_secure_installation


Download the latest from the  .  Create a new folder in your Sites folder called phpmyadmin and extract  the downloaded files to that location.

$ curl -O
$ unzip
$ mv phpMyAdmin-4.6.3-all-languages phpmyadmin
$ mv phpmyadmin ~/Sites/

Edit your httpd.conf file , pretty much anywhere and add

Alias /phpmyadmin "/Users/{_USE_YOUR_USERNAME_}/Sites/phpmyadmin/"
<Directory "/Users/{_USE_YOUR_USERNAME_}/Sites/phpmyadmin/">
     Order allow,deny
     Allow from all
     Require all granted

Save the file and restart your apache server

sudo apachectl -k restart

browse to http://localhost/phpmyadmin and all should be running.


Helpful Resources

Follow Me

Gary Woodfine

Helps businesses by improving their technical proficiencies and eliminating waste from the software development pipelines.

A unique background as business owner, marketing, software development and business development ensures that he can offer the optimum business consultancy services across a wide spectrum of business challenges.
Follow Me

Latest posts by Gary Woodfine (see all)

%d bloggers like this: