Vagrant logotype

If you work on Drupal and need other people to work with you or for you, there’s always a time where you’ll feel the need for sharing a dev environment in an efficient way. There’s plenty of ways to do this; this article is about the most simple one: Vagrant with Shell scripts provisioner.

Pick the right tool

If you look for an Open Source way to package and redistribute an environement, you’ll most probably hit these 2 folks:

VirtualBox is a virtualization platform, and Vagrant is a tool to build development environments. They work together well, and have install packages for OSX, Windows and Linux. That’s an important criteria for me: I am on OSX, but some of my fellow developers are on Windows, so I need something that installs easilly and runs everywhere.

Once you are set with VirtualBox and Vagrant, comes the question of provisioning: how will you ensure that your virtual machine runs the required software?

If you have a look to Vagrant documentation, you’ll see that there’s a lot of choice of provisioning methods: Shell scripting, using Chef1, using Puppet2, using Docker3 (the trendy folk for Ruby lovers ;), etc.

Shell provisionning + repackaged boxes

I work with Drupal, so this article is targeted at Drupal. When it comes to provisionning, let’s try to see what I need:

  • I need an Apache2 stack, with Solr4 and Xdebug5, + a few PHP libraries.
  • I don’t need to change core PHP or libs versions often, maybe only when I start using a new version of Drupal.
  • My production environment is Ubuntu 12.04 LTS, I’m perfectly fine with it, I’m happy to have the same for dev.

Instead of trying some fancy provisionners like Chef or Puppet, I decided to go for Shell scripting provisionning, and repackage my box to keep a way to fine-tune it if needed, per project.

HOWTO: Vagrant + Drupal + Solr + Xdebug

Thanks to this article from Wunderkraut’s Jurgen Verhasselt, I was able to produce a Vagrant box with a full working Apache2 stack + Solr + Xdebug. It is not Drupal specific, so you may even use it for Symphony, Joomla or any other PHP framework/CMS.

Then, I created a second Vagrant box for Drupal, that uses the previous one as a base, and do some little tuning to make it Drupal-ready: changing PHP settings (MEMORY_LIMIT, etc.) and configuring Solr for Drupal.

The provisioning scripts for these 2 projects are available on 2 public GitHub repositories, feel free to use/reuse/modify according to your needs!

Where to start

I would recommend the following:

  1. Chef and Chef Solo

  2. Puppet

  3. Docker, “The Linux container engine” and “What is Docker”, by Louis-Alban Kim

  4. Apache Solr is a search-engine platform that can boost the search capabilities of your Drupal project

  5. Xdebug is a must have debugger for PHP, that can integrate with your development IDE.