Using Vagrant as a WordPress Development Environment: Part 1

In the past, I’ve used XAMPP for local WordPress theme development, but have been reading and hearing lots about Vagrant. Last weekend, I decided to give it a try.

Unlike XAMPP, the idea behind Vagrant is to run a virtualized OS environment from within a program like VirtualBox. These virtual environments are distributed via a catalog of base images (known as “boxes”). The catalog is comprised of user contributed and customized boxes. Vagrant has a nicely written tutorial on it’s site to get you started creating your first virtual environment from one of these boxes. Unfortunately, at least for me, there were some complications along the way.

Initial Setup

After installing both Vagrant and VirtualBox, and initializing your project directory, it’s time to install your first “box.” Vagrant recommends testing out a box called “hashicorp/precise32” which is a base image of Ubuntu 12.04 LTS 32-bit.

I’m primarily a Windows user, so I carried out all of my commands simply using the Windows Command prompt. After executing the “vagrant box add hashicorp/precise32” command, the box download begins. One of the nice things about Vagrant is that these boxes can be reused by multiple Vagrant environments, so there’s no need to download the same box twice.

Next, after downloading, it’s time to edit the auto-generated “Vagrantfile” to tell Vagrant that you’d like to use the box you’ve just downloaded as your virtual environment. Once configured and saved, it’s just a matter of returning to the command prompt and executing “vagrant up” to launch your box.

The First Hiccup

During the launch process, Vagrant boots up the specified Ubuntu box in VirtualBox. By default, you don’t see this process taking place from within the VirtualBox GUI — all we’re given are some messages on the command prompt relaying the boot status.

Of course, my first attempt at booting resulted in an error. Launching VirtualBox I was presented with an unhelpful error message:

VT-x is not available. (VERR_VMX_NO_VMX).

Turns out, VirtualBox does not play nice with Windows Hyper-V — VT-x is hardware virtualization that is usurped by Hyper-V and VirtualBox needs it to work. Disabling Hyper-V cleared this error, but uncovered another.

In the next part of this post series, I’ll wrap up troubleshooting my initial Vagrant setup, launch and SSH into the test Ubuntu box and take a look at a couple other boxes that come distributed with a LAMP stack for WordPress development.

Leave a Reply