Varun Yellina

OSX Fresh Install Semi Automatic Setup

Getting upto speed effortlessly.

EDIT1: Updated for Yosemite (10.10)
EDIT2: Updated for El Capitan (10.11). Untested on 10.10 & 10.9

Xcode command line tools

We need the xcode command line tools to compile stuff. So

$ xcode-select --install

Accept the dialog box to install the tools. You may download XCode from the App Store if needed.


Zsh has some nifty features over bash, particularly the recursive globbing.

$ curl -L | sh


It’s nice to have a package manager do the work.

$ ruby -e "$(curl -fsSL"

Now that homebrew is up and running, let’s get some tools and apps. The below linked gist can be downloaded as a shell script and executed. While you’re at it, you can add your own tools and apps to the list.

Git setup

$ ssh-keygen -t rsa -C ""

copy ssh key to

$ ssh-add ~/.ssh/id_rsa

copy ssh key to clipboard, add it to your ssh keys on github and bitbucket.

$ pbcopy < ~/.ssh/

test connection

$ ssh -T

set git config values

$ git config --global "Varun Yellina"
$ git config --global ""
$ git config --global github.user varunyellina
$ git config --global github.token your_token_here
$ git config --global core.editor "subl -w"
$ git config --global color.ui true


Node and npm can be installed with homebrew. Node now comes with npm.

$ brew install node

Fix permissions to allow installation without sudo.

$ sudo chown -R `whoami` /usr/local/lib/node_modules
$ sudo chown -R `whoami` ~/.npm

Install grunt and bower

$ npm install -g grunt-cli
$ npm install -g bower


Install nginx

$ brew install nginx

Next change nginx port to default http port 80

$ nano /usr/local/etc/nginx/nginx.conf


  server {
        listen       8080;


  server {
      listen       80;

Now let’s get it running

$ sudo cp -v /usr/local/opt/nginx/*.plist /Library/LaunchDaemons/
$ sudo chown root:wheel /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist


$ brew install dnsmasq
$ mkdir -p /usr/local/etc/
$ echo "address=/dev/" >> /usr/local/etc/dnsmasq.conf
$ echo "listen-address=" >> /usr/local/etc/dnsmasq.conf
$ sudo cp -fv /usr/local/opt/dnsmasq/*.plist /Library/LaunchDaemons
$ sudo launchctl load -w "/Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist"
$ sudo -s
$ sudo mkdir -p /etc/resolver
$ sudo echo 'nameserver' > /etc/resolver/dev
$ dscacheutil -flushcache

Dynamic virtual hosts

Now that we have installed dnsmasq to resolve domains ending with .dev to point to, let’s configure nginx to dynamically configure virtual hosts.

I configured my nginx to use /Users/varun/Sites folder as webroot.

Now let us say I have my websites in this order





We have to create a separate folder for all our sites.

$ mkdir -p /usr/local/etc/nginx/sites-available/
$ mkdir -p /usr/local/etc/nginx/sites-enabled/

Since that is done, we have to tell nginx about the locations. Edit the nginx.conf and include the follwing line in the http {} section

  include /usr/local/etc/nginx/sites-enabled/*;

Now, let’s put in a default config. I’ve a gist which we’ll make some changes to.

$ curl -L | sed -e "s/varunyellina/$USER/" > /usr/local/etc/nginx/sites-available/default

Next, we’ll put in a config that’ll resolve all .dev domains to the respective folders in /Users/yourusername/Sites folder.

$ curl -L | sed -e "s/varunyellina/$USER/" > /usr/local/etc/nginx/sites-available/localsite

We now enable the config by using a symlink.

$ ln -s /usr/local/etc/nginx/sites-available/localsite /usr/local/etc/nginx/sites-enabled/localsite

Now just restart your nginx service, and you are good to go.

$ sudo nginx -s stop
$ sudo nginx

Accessing your local website is automatic now.

~/Sites -- localhost
~/Sites/portfolio --
~/Sites/survey --
~/Sites/portal --


brew install mariadb Install databases

$ unset TMPDIR

$ mysql_install_db --user=`whoami` --basedir="$(brew --prefix mariadb)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

Now start mysql server

$ mysql.server start

Change root password and remove test databases. The default password is either root or there is no password, just hit return.

$ /usr/local/opt/mariadb/bin/mysql_secure_installation

Start mariadb on boot

$ ln -sfv /usr/local/opt/mariadb/*.plist ~/Library/LaunchAgents


$ brew upgrade && \
$ brew tap homebrew/dupes && \
$ brew tap homebrew/versions && \
$ brew tap homebrew/homebrew-php && \
$ brew install freetype jpeg libpng gd zlib && \
$ brew install --with-fpm --with-mysql php56
$ ln -sfv /usr/local/opt/php56/*.plist ~/Library/LaunchAgents
$ mkdir -p /usr/local/etc/nginx/conf.d/

Add php-fpm configuration to the file at /usr/local/etc/nginx/conf.d/php-fpm

location ~ \.php$ {
  try_files  $uri  $uri/  /index.php?$args ;
  index  index.html index.htm index.php;
  fastcgi_param PATH_INFO $fastcgi_path_info;
  fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_index index.php;
  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  fastcgi_intercept_errors on;
  include fastcgi_params;

Load php-fpm

$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist