Vagrant, no more MAMP?


Vagrant, what is it?

Vagrant is a command line manager for VM (Virtual Machines). Vagrant allows developers to create and manage virtual machines using the command line, and most important of all, allows developers to specific say what they what to be included in that VM.

Vagrant was created by Mitchell Hashimoto (@mitchellh).

You can think of Vagrant as a “Virtual Machine Configurator and Manager”. Image that you go to a website and you can customise the car that you want to buy. You can choose the interior/exterior colours, type of engine, etc. This is what Vagrant does for you. You specify what you want to be included in the VM and Vagrant handles the rest.

That previous example was a little bit weird for a developer. Let me try to explain in another way. How many times, you had to setup one host so that you can work on a project? How much of that environment resembles the final production server where that project is going to be deployed? Probably you know that it uses LAMP, and you just fire up MAMP, and start coding.

How cool it would be that you could have an environment equal to the production server? With Vagrant you can. Just tell what you need and Vagrant creates that environment (VM) for you.

How to get started?

First of all you need to have install VirtualBox.

Then you need to download and install Vagrant. Just click the latest version, and choose the correct file for your OS.

After downloading and installing Vagrant you just need to create an empty directory for your project. And inside of it run the command:

and you get something like this:

A Vagrantfile has been placed in this directory. You are now

ready to vagrant up your first virtual environment! Please read

the comments in the Vagrantfile as well as documentation on for more information on using Vagrant.

if you try listing the directory you get something like this:

This creates a simple .vagrant directory, and a Vagrantfile. This Vagrantfile is where we specify all of our configurations and specifications.

The Vagrantfile looks something like this:

NOTE: I’ve removed most of the comments in the file.

Now if we run the command:

you get something like this:

This make take a while, but only for the first time. You can change and update all the configuration and run the command:

and Vagrant will update the VM to the specified changes.

Soo now we have a VM at our disposal. Just run the command:

and we get something like this:


now we are inside a Linux VM.


Vagrant works with something called a “box”. What is a “box”?

Well a box, is a pre-made VM (bootstrap) for the VM that you want to build and customise. So every VM that you want create/modify to your needs, starts with another “clean” VM.

In this default example, since we did not specified any box, Vagrant uses a Linux Ubuntu box called lucid32. There are a lot of box’s that we can specify that we want to be our base box. Please check this link ( more information about it.

If we take a look at our Vagrantfile we have this line where we can specify the url of the bootstrap box that we want:

just change it to something like:

By making this simple change, instead of using the Linux Ubuntu Lucid32, we are using, CentOS 6.2 32bit (with puppet).

The Vagrantfile is very simple and easy to understand. For more information, please take a look at the documentation.


Vagrant has a lot of more configurations and providers (Puppet, Chef, etc) that help to configure everything that you want to be installed in the VM. And has the main ability, that you can share the Vagrantfile with team developer and he will get the same VM to work.

I’ll be posting some more information soon explaining how can you achieve your perfect VM.

1 comment

  1. Hey Pedro,
    thanks for introducing vagrant. To be honest, I haven’t seen or used it before. I’m also not a big fan of coding in a VM, although it’s a save and individual setting. Maybe you can convience me on some further posts, where you will show, how to set up a perfect VM :-)

    bye dan

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">