Last updated on the .
Originally, these were the notes I took down when setting up the development environment on my new MacBook Air in June 2012, but it’s now become a step by step guide to setting up a full development stack on Mac OS X 10.8 Mountain Lion. I’ll aim to keep this post up to date with the latest dev environments/workflows as new tools are released in order to setup the leanest/efficient development machine possible.
The only prerequisite is an up-to-date install of OS X 10.8 Mountain Lion.
- Install Homebrew
- Install Git
- Install RVM
- Install Node
- Install MySQL
- Install CouchDB
- Configure Apache
Using Sublime Text 2 from the Command Line
Before we begin, i’d recommend enabling Sublime Text 2 Command Line support as, for some reason, this isn’t available out of the box.
To setup the command line functionality, type the following into the terminal.
Homebrew has two dependencies: XQuartz, and Xcode*.
It’s a common delusion that the entire 2.8gb install of Xcode is required, however, the only part of Xcode Homebrew requires, is the Command Line Tools.
As of the 26th July 2012, Apple has dropped X11 from its OS. OS X Mountain Lion does not come bundled with X11, and instead, Apple recommend developers install the more up to date open source XQuartz project, which it will continue to support.
Download XQuartz here then install it, log out, then log back in.
Command Line Tools
Homebrew requires Xcode to be installed in order to work, but Xcode is massively bloated for what is actually required by homebrew to build apps.
OSX-GCC-Installer by Kenneth Reitz was a way round this bloat, but lacked the 10.6/7 SDKs due to licensing restrictions. Apple, however, took interest in this project and were keen to ship something official.
Thus, Apple announced the Command Line Tools for Xcode. It’s a 171 MB download that includes all of the tools Homebrew should ever need. Plus, Homebrew officially supports this package.
Download the Command Line Tools for Xcode here and install it.
1.2 Installing Homebrew:
The script installs Homebrew to
/usr/local so that you don’t need sudo when you brew install.
It’s bad practice to install packages using sudo.
Packages can run arbitrary scripts, which makes sudoing a package manager command as safe as a chainsaw haircut. Sure, it’s fast and definitely going to cut through any obstacles, but you might actually want that obstacle to stay there. — Isaac Z. Schlueter
1.3 Changing ownership of usr/local:
This step isn’t required for brew, but since we’re on the subject of sudo, i recommend changing ownership of
$user. This will benefit you when using node’s package manager, and will mean you won’t have to use sudo when installing into
There is a massive debate about chown-ing
/usr/local, and i agree with Isaacs comments here.
Next, to setup git. Run the following commands in the Terminal.
Make sure you use the same email address for Git, GitHub, and Heroku.
RVM stands for Ruby Version Manager. It’s a command line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems. It also installs gems to your
~/ home directory, instead of using the global root of your machine.
RVM helps improve security
RVM helps ensure that all aspects of Ruby are completely contained within user space, strongly encouraging safer, non-root use. Use of RVM rubies thus provides a higher level of system security, and therefore reduces risk and cuts overall system downtime. Additionally, since all processes run at the user level, a compromised ruby process cannot compromise the entire system.
Say goodbye to sudo gem installs
Yep, that’s right! By using RVM, you won’t have to
sudo to install gems on your machine.
3.1 Install the stable release version:
Finish the installation by either running the following command, or closing all shell windows.
Replace username with your Mac username.
Before installing the latest version of ruby with rvm, we need to install
According to the node docs, Brew installs of node are known to be buggy, the node package manager is not included in the install etiher, so the node devs themselves reccommend using the Macintosh package installer:
Note (8th Feb 2013):
Node devs recently made some changes so that Node no longer installs on OS X via homebrew if Xcode is not installed. We haven’t installed Node via homebrew, however this issue still affects us.
Next time you run npm install you may come across the following error:
To fix this, all you need to do is:
Yeoman is a robust and opinionated set of tools, libraries, and a workflow that can help developers quickly build beautiful, compelling web apps. Tools included are, Yo (a scaffolding tool), Grunt, Bower and more.
Sidenote - Debugging / $PATH issues
I actually had a few issues at this point with my new MacBook air and had to roll back the install of MySQL in order to fix a few issues…
brew doctor to discover that
/usr/bin was ahead of
/usr/local/bin in my $PATH.
In order to get round this, i needed to edit
/etc/paths to fix the order.
This isn’t a file i recommend playing with often. However, i’ve mentioned it here, as it might come in handy to people needing to do a little DIY machine debugging.
Opening a new terminal window and running
brew doctor again should confirm this.
You’re then requried to setup a few things. Run the following commands:
Followed by the following: (you might also need to restart your machine to fix a conflict with Lion’s copy of MySQL.)
Then use the alternative security script:
CouchDB is a popular NoSQL database.
If you’re not planning on developing node apps with persistent storate, you can skip this step.
Type the following command in to edit the
httpd.conf file in Sublime Text.
7.1 Enable PHP5
line 111 and un-comment:
Find and uncomment the following line. It can be found around
7.3 Creating a Virtual Hosts File
You then want to create a vhosts file, to store all your virtual hosts in. So enter the following commands in the Terminal.
And enter the following:
Change username, sitename, dev, and dev.foo accordingly, and save the file.
7.4 Pointing Localhost to a Virtual Host Server Name
Now we need to point localhost to the server name, in order to enable the virtual host.
And enter the following on a new line and save:
7.5 Restart Apache, and Lock ‘N’ Load!
System Settings disable and re-enable
Web Sharing in the
Fire up your favourite web browser and enter the servername, you should be pointed to the doc root you entered in your vhosts file!
Now, there are plenty more options you can set for logs etc, but i’ll leave that out as not to over complicate this article.
8.0 Remaining packages:
There are a lot more packages that can be installed, and need less configuration than the ones mentioned above. I’ve put these in a .dotfile you can download here, and can be batch executed calling: