---

How To Install And Setup Vagrant

Vagrant is a powerful tool when it comes to virtual machines, here we will look at how to setup and use Vagrant with Virtualbox on Ubuntu to provision reproducible virtual machines.

Virtual Machines, not all that complex

For years, developers have been using virtual machines as part of their workflow, allowing them to swap and change environments that the software is running in, this is generally to prevent conflicts between projects such as project A needing php 5.3 and project b needing php 5.4.

Also, using Virtual Machines means you only ever need the computer you’re working on, you don’t need dedicated hardware to mirror the production environment.

It also comes in handy when multiple developers are working on one project, they can all run an environment which contains all of its requirements, but it can be hard maintaining multiple machines and ensuring all have the same versions of all the requirements, this is where Vagrant comes in.

The benefits of using Virtual Machines

Your vm is separate from your host environment
You can have a vm tailor for the requirements of your code
Anything done in one vm does not effect another VM
You can run programs in a vm which your host may not be able to run, such as running some windows only software in a – windows vm on top of ubuntu
What is Vagrant

In short, it’s a tool that works with virtual box to allow you to automate the creation and removal of a virtual machines.

It revolves around a Config File Called the VagrantFile, which tells vagrant what version of what os you want to install, and some other options such as the IP and Directory Syncing. You can also add a provisioning script of commands to run on the virtual machine.

By Sharing this VagrantFile around, all developers on a project. You will all be using the exact same virtual machine.

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends, & analysis