Entity view (Content)

Developing with Vagrant

By aali
Jun. 8, 2012

I’ve been doing web development for the past 7 years using a multitude of different setups. I started using a Windows PC with WAMP. I then started doing development on an Ubuntu machine using a more traditional stack. Using apt-get I was able to run and configure mysql, apache, PHP and all the PHP extensions pretty easily. After a couple of years developing on Linux I moved over to a Mac. I was amazed to see the offerings Mac had for local development environments, such as Homebrew, MAMP, and MacPorts. I chose to use MacPorts as it was the closest to a traditional stack like I had on Linux. I had, what I believed to be the perfect setup and I did, but how could I get this across to everyone on my team without interfering with their local setups?

Enter Vagrant. What is Vagrant? It’s basically a way to package a virtual machine in a lightweight, reproducible and portable manner. This allows me to setup a virtual machine, or a box as Vagrant calls it, and package it up so it can be used by other developers. This way I can make sure everyone’s setup is exactly the same, and there are no hacks or workarounds to the code for local environments. I normally like to create specific boxes to mimic each type of server I’d need.

So I can setup a Tomcat/Solr server for ApacheSolr integration and a simple web server for web development. Once I’m done configuring everything the way I need it in VirtualBox, I can use Vagrant to package into a box. I like to put these boxes on the internal network so people can just download them at their will. Having these packaged boxes allows me to setup and tear down boxes whenever I need one. Vagrant can do a lot of neat things like creating multi-vm setups, where you can use separate VM’s for the web server, database server, and reverse proxy server, if you had a complicated setup like that. It also does provisioning, so using a tool like Chef or Puppet you could automatically provision your servers, which means you wouldn’t even have to manually configure the packages yourself the first time around because the provisioner would handle installing and configuring the packages.

Vagrant is a great tool to have in your toolbox. I would suggest reading more on the Vagrant website to get it up and running!

Post Tags: