Setting up a Mac for Web Development


Setting up a mac, brand new or clean, all the way to a software development monster can become a hassle, even if it is not your first time you often forget dependencies or “that” code to download a specific thing. In this post I will go with the steps and tools I use for setting up a clean machine until you get a neat little package to start working.

We will be installing the Xcode CLI tools, Homebrew, git, RVM, node.js and npm, your own or someone else’s dotfiles and Rupa Z.

This tutorial was tested with Mac OSX Mountain Lion and Mavericks.

Part 1: Install Xcode CLI Tools via Xcode.

Ok, so we need to install Xcode. Xcode is necessary to install further software like Homebrew.

First go to this link to Xcode on the Mac App Store, then click on View in Mac App Store.

Screenshot 2014-04-10 20.05.17

It will automatically open the App Store on your Mac. Click the “Free” button and then Install App.

When it finishes open Xcode and go to its Preferences by going Xcode>Preferences or by the hotkey ⌘ + ,. Go to the Downloads tab and then click on Install button next to Command Line Tools.

Screenshot 2014-04-10 20.59.14

Part 2: Install Homebrew

Homebrew is the missing package manager for OS X”, and allows us to easily install tons of software. For example you can install chrome, git, wget and much more with the simple command brew install.

The full install instructions are a good read but you should only need to run this on your terminal. Your Terminal should in your applications folder or you can CMD + spacebar to open Spotlight and type Terminal.

ruby -e "$(curl -fsSL"

Follow the instructions and when it finishes run the following command on the terminal.

brew doctor

If you get Your system is ready to brew Homebrew was successfully installed and you can move on. If you didn’t don’t panic, follow the next instructions to fix errors and warnings you might get.

If you get Error: No such file or directory -- /usr/local/Cellar run the following command which creates the directory.

sudo mkdir /usr/local/Cellar

sudo allows you to run commands as a user with higher access rights, which is why it prompts you for your password, and mkdir stands for “make directory.”

If you get Warning: /usr/bin occurs before /usr/local/bin run this

echo 'export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"' >> ~/.bash_profile

Quit and relaunch Terminal, then run brew doctor once more to verify. Your system should be ready to brew now.

Part 3: Install git

git is my version control system of choice. A version control system keeps tab of all the changes you make to the files to tell him to. So for example, if you want to see the changes you did to a file a week ago you can do that with ease, and that’s just the tip of the iceberg.
I use git constantly to keep my personal files on check and to use Github.
With Homebrew installing git is super easy

brew update
brew install git

Note It’s a good habit to run brew update before installing anything with Homebrew because Homebrew is updated often.

Run brew doctor to make sure everything is still working. If you get Warning: /usr/bin occurs before /usr/local/bin, run this:

echo 'export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"' >> ~/.bash_profile

Run brew doctor to make sure everything is still working. Now to check git run

which git

You should get /usr/local/bin/git. Now to configure git we need to run the following commands, if you use Github make sure the email is the same for git and Github.

git config --global "Your Full Name"
git config --global "Your Email Address"

Part 4: Install RVM with Ruby and Rails

RVM means Ruby Version Manager, and is one of the most popular tools that allows you to install and manage multiple versions of Ruby and Rails on the same computer.

You can install RVM in one simple command

\curl -L | bash -s stable --rails --autolibs=enable

When it finishes quit the terminal and run

type rvm | head -1

If you installed RVM successfully you should get rvm is a function.

Part 5: Install node.js and npm

node.js is a platform built on Chrome’s JavaScript runtime. NPM is Node’s package manager that will let us install some really interesting and useful software like grunt, requirejs, bower and much more. To install Node.js we run

brew install node

And npm is now installed automatically with Node.js so there is no need to do a separate installation. To test if NPM was installed run

npm -v

You should get your npm version. Mine was 1.2.18

Part 6: Dotfiles

The Dotfiles are a compendium of configurations for you Mac. This configurations vary from making your Mac faster on load to changing the color of your terminal.Dotfiles are called like that because the filename begins with a . and are usually found in the user’s home directory. These files are created as you install and configure your machine. Starting a fresh Dotfiles can be a daunting task but lots of awesome people have open sourced theirs so you don’t need to worry. I personally use Mathias dotfiles but here are some popular Dotfiles:
Mathias Bynens
Paul Irish
Zach Holman
Yan Pritzker

To install Mathias Dotfiles first you need to download them

git clone && cd dotfiles

Now run the bootstrap script


Finally run the osx to and restart

source .osx

If you want to know more about Dotfiles, this is an awesome tutorial.

Part 7: Rupa Z

Rupa Z is an amazing shell script that allows users to go from folder to folder with minimal effort. So instead of writing

cd this/is/a/really/long/path/that/i/need/to/get/so/i/can/start/working

You can write

z working

Sounds awesome right? To install first run

cd ~
git clone
chmod +x ~/z/

Then will need to add some code at the end of your .bash_profile which is at your root directory. To open it run

nano .bash_profile

Then add the following at the end of the file

# init z
. ~/z/

Finally to exit nano just click Ctr+X and then press Y. And you are done. To test it cd to one of your folders and then try doing it with z.


That’s all for now! Go forth, have fun with your new super machines and the next time you need to set up a machine from scratch, you can smile to yourself as the whole process is here for you to come back.