website design gold coast
website design gold coast

Our Mac Dev Setup

Here is our fine-tuned guide to setting up your local MAC web development environment.

Extending on Chris Mallinson great tutorial here we have fine-tuned this guide for our WordPress setup and made some updates for the latest version of OSX which we will endeavour to keep up to date.

After toying with Vagrant boxes for a year or two we have gone back to the simplicity and “always on” speed of this native setup. The downside is it can be tricky to setup and easy to break.

XCODE

To start your journey, you will need to set up Xcode, Apple’s own software development bundle. You can grab this from the App Store or (for all OS X Mavericks 10.9 and higher) run the below command in terminal.


xcode-select --install

Click install on the dialogue box and wait for it to complete. Once it’s installed, you will need to start up the app – the tools won’t work unless it has been started up at least once – then accept the licence agreement and shut it down.

 

HOMEBREW

Next, you will need to install Homebrew, a popular package manager for OS X, by running the below command in terminal.


ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

 

MYSQL

Run the below command in terminal to install MySQL.


brew install mysql

 

DNSMASQ

Finally, run the command below in terminal to install dnsmasq. This allows wildcard subdomain names.


brew install dnsmasq

 

APACHE

Now we have to set up Apache, a cross-platform web server, which is where we will store our web files. Get this started by running the below command in terminal.


sudo apachectl start

To test this is working, head over to http://localhost/ in your browser. You should see a page that says “It Works”.

 

If it’s working, the easy part is done!

Now we need to make a few quick changes to the configuration files. Run the following command in terminal.

 

Edit httpd.conf


sudo nano /private/etc/apache2/httpd.conf

Then use the terminal search feature (ctrl + w) to find and uncomment (remove the ‘#’) the following lines:


#LoadModule php5_module libexec/apache2/libphp5.so


#LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so


#Include /private/etc/apache2/extra/httpd-vhosts.conf

 

Then, using the same search (ctrl + w) find and comment out (add a ‘#’ in front of each line) to the following:


 <Directory />
     AllowOverride none
     Require all denied
 </Directory>

This will give Apache full access to your file system and help direct all your files and virtual hosts to the right places.

 

Next, to give writing access to all your site directories, run the following command in terminal.

Search for your username and then ensure that group is changed to staff as seen below. User should be set your your user.


#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User USER
Group staff

Edit httpd-vhosts.conf

Next, run the below command in terminal to find the next file we need to edit.


sudo nano /private/etc/apache2/extra/httpd-vhosts.conf

Look for the following lines, and ensure that __user__ matches your username (hint: whoami).

And also /Users/__myfolder__/www/sites/%1/public matches you website locations!


<Directory "/Users/__user__/www">
  Options Indexes MultiViews FollowSymLinks
  AllowOverride All
  Require all granted
</Directory>

<Virtualhost *:80>
  VirtualDocumentRoot "/Users/__myfolder__/www/sites/%1/public"
  ServerName sites.dev
  ServerAlias *.dev
  UseCanonicalName Off
</Virtualhost>

Now restart Apache by running the following line in the terminal.


sudo apachectl restart

Now make a test website at the path you defined in httpd-vhosts.conf and you should be able view it at your foldername.dev !

Done. Please let us know if you have any more tips or feedback to help others.

When updating OSX?

  1. Before you update your OS X, make sure to backup your httpd-vhosts.conf file as this will most likely be overwritten! If it’s too late you will need to recreate this file as above.
  2. Then, after updating, find your way into your httpd.conf file and confirm that all the correct lines are edited (as we did above). This is extremely important as they will most likely has been altered during the system update!

 

Sharing is caring:

Created Dec 1, 2017 Made on the Gold Coast

Leave a Reply