Vagrant

Create and configure lightweight, reproducible, and portable development environments. Vagrant is a tool for managing virtual machines via a simple to use command line interface.

Prerequisite

You’ll need homebrew-cask, if you don’t have it refer to this section.

Installation

Vagrant uses Virtualbox to manage the virtual dependencies. You can directly download virtualbox and install or use Homebrew for it.

  1. $ brew cask install virtualbox

Now install Vagrant either from the website or use Homebrew for installing it.

  1. $ brew cask install vagrant

Vagrant-Manager helps you manage all your virtual machines in one place directly from the menu bar.

  1. $ brew cask install vagrant-manager

Usage

Add the Vagrant box you want to use. We’ll use Ubuntu 12.04 for the following example.

  1. $ vagrant box add precise64 http://files.vagrantup.com/precise64.box

You can find more boxes at Vagrant Cloud.

Now create a test directory and cd into the test directory. Then we’ll initialize the vagrant machine.

  1. $ vagrant init precise64

Now lets start the machine using the following command.

  1. $ vagrant up

You can ssh into the machine now.

  1. $ vagrant ssh

Halt the vagrant machine now.

  1. $ vagrant halt

Other useful commands are suspend and destroy.