My Mac Web Dev Setup

The main reason for the following post is for my personal benefit, so I can reference it and remember exactly how I setup everything when I need to do it again. Hopefully someone else can get something useful from this article, but really, that’s just a bonus. With that said, enjoy.

Before doing all the terminal stuff, you probably want to start with downloading iTerm. This is one of the best Terminal alternatives for Mac.


First (real) step, install Homebrew

Homebrew is an essential part of Mac development. It bills itself as “The missing package manager for macOS”. With it we can quickly and easily install any number of packaged applications, utilities, and services.

Open up the terminal and paste the following snippet to download and install Homebrew.


/usr/bin/ruby -e "$(curl -fsSL"

Since we’re going to use the built-in macOS web server, we’ll just setup MySQL

After installing Homebrew, installing other things, like MySQL, is super easy. Just type the following command into your terminal.

brew install mysql

Here’s a little fix if later you can’t access your MySQL databases over Socket

// Reference:
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

Using DNSMasq for wildcard URLs and Redirects

// setup dnsmasq for smart urls and redirecting
brew install dnsmasq

Edit the DNSMasq parameters to fit your local network setup/IP

echo 'address=/. localhost/' > $(brew --prefix)/etc/dnsmasq.conf
echo 'listen-address=' > $(brew --prefix)/etc/dnsmasq.conf

This will add the following to your dnsmasq.conf configuration file (/usr/local/etc/dnsmasq.conf)


Setup the DNSMasq resolver directory for your IP address

// create dnsmasq resolver directory and file where is your computer's static IP address
sudo mkdir -v /etc/resolver
sudo bash -c 'echo "nameserver" > /etc/resolver/localhost'

Restart DNSMasq

sudo launchctl stop homebrew.mxcl.dnsmasq
sudo launchctl start homebrew.mxcl.dnsmasq

Now, on to the Apache setup

Sorry, no easy terminal commands for this part. Just search through your apache configuration file for these bits and either replace, remove, or comment out.

While I use Sublime Text for pretty much everything else, I use Atom for this. Atom is a wonderful text/code editor and it’s great for editing system files without a problem.


// set the server name
ServerName localhost

// edit the apache config file /private/etc/apache2/httpd.conf
<IfModule unixd_module>
User jonathan // add your username here
Group _www

// uncomment these modules
LoadModule deflate_module libexec/apache2/
LoadModule expires_module libexec/apache2/
LoadModule rewrite_module libexec/apache2/
LoadModule vhost_alias_module libexec/apache2/

// Before High Sierra, uncomment this
LoadModule php5_module libexec/apache2/
// Using High Sierra or beyond, look for something like this:
LoadModule php7_module libexec/apache2/

// comment out this
# <Directory />
# AllowOverride none
# Require all denied
# </Directory>

// change these directories to your web server root (the place you're hosting your sites locally)
DocumentRoot "/Users/jonathan/Documents/www"
<Directory "/Users/jonathan/Documents/www">

// uncomment the "httpd-vhosts.conf" file for the virtual hosts to work with dnsmasq
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

Finally, the Apache Virtual Hosts configuration

Edit the apache vhosts configuration file (/private/etc/apache2/extra/httpd-vhosts.conf)

This uses a free little micro service called for redirecting stuff on your local network using nice, easy to read URLs.

<Directory "/Users/jonathan/Documents/www">
 Options Indexes MultiViews FollowSymLinks
 AllowOverride All
 Order allow,deny
 Allow from all

<Virtualhost *:80>
 VirtualDocumentRoot "/Users/jonathan/Documents/www"
 ServerName home.localhost
 UseCanonicalName Off

<Virtualhost *:80>
 VirtualDocumentRoot "/Users/jonathan/Documents/www/%1"
 ServerName sites.localhost
 ServerAlias *.localhost
 UseCanonicalName Off

// Forget this
<Virtualhost *:80>
 VirtualDocumentRoot "/Users/jonathan/Documents/www/%-7+"
 ServerName nip
 ServerAlias *
 UseCanonicalName Off

Now, restart the Apache server and MySQL for good measure

sudo apachectl -k restart
mysql.server restart

Network DNS settings

In the System Preferences > Network section you’ll need to add an additional DNS server to your network connection (ethernet or wifi). Click on the “Advanced…” button for your active connection and then the DNS tab at the top of this dialog. Here you’ll need to use the + (plus) button to add, first your development machine’s IP address (in my case it would be the same one I’ve been using in the examples:, then the base IP address for your network (generally: After that I usually add in at least one of Google’s DNS addresses ( or [Read more about that here].

The best, free, SQL database manager for Mac: Sequel Pro


Once, downloaded, unzip and move the Sequel Pro app to your Applications folder. Now, open it and setup a Socket connection. All you need is to enter “root” in the user field for now. If everything was setup correct you can now connect directly to your local MySQL server and start setting up your databases.

The first thing I like to do is setup a user for all my local databases.

Command+U brings up the User Accounts dialog. Press the + (plus) button at the bottom left of the User Accounts dialog and enter your username and password. Then go to the “Global Privileges” tab and press the “Check All” button and finally, the “Apply” button to save your new user account.

That’s it for database setup. Now you can add all the local databases you want.