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

https://github.com/threenine/PoorMansMamp

PHP

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

DNSMASQ

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 http://projectname.dev

Apache

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.

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

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

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

Create a php info page

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

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

finder

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

create

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

MySQL

Installing mySQL is really easy using HomeBrew.

Start your MySQL server

Don’t forget to secure your mysql installation

phpmyadmin

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

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

Save the file and restart your apache server

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

 

Helpful Resources

Gary Woodfine

Founder & CTO of threenine.co.uk. Experienced full stack software developer well versed in delivering web & mobile applications utilizing cloud architectures. Areas of speciality include cross platform development in .net , PHP, JavaScript.

π
%d bloggers like this: