I've been slowly trying to work Vagrant into my workflow. I've found it best to use it when starting new projects (most of my old projects already have a existing VM) but the last couple days I've been fighting a problem where every PHP script on a VM takes 5 seconds to finish. I've tried everything from completely destroying the VM and starting over, creating a new PuPHPet configuration, and trying a different networking setup. In desperation, I tried changing the base box that Vagrant used from 64 to 32 bit and then downgraded from Ubuntu Precise 12.04 to Ubuntu Lucid 10.04 and I was shocked when those had no effect on what VM Vagrant used.

For this example, I'm going to use the Wordpress with Vagrant repo I used when I wrote the Getting Started With Vagrant article. If you want to follow along you can clone this yourself.

The first step is that I'm going to create a simple file called phpinfo.php in the public directory with the following code:

<?php
phpinfo();

This way we have an easy way to see what version of Ubuntu the VM is running.

If we vagrant up this repository and then access this page (http://localhost:8080/phpinfo.php) you'll get the following result.

From this we can see that it installed precise32 (12.04).

So let's attempt to change our Vagrantfile so we install precise64 instead. I assumed I would just need to change this line:

config.vm.box_url = "http://files.vagrantup.com/precise32.box"

To:

config.vm.box_url = "http://files.vagrantup.com/precise64.box"

And once we perform a vagrant destroy and then a vagrant up we should get precise64!

So that didn't work... :-(

After some digging I figured it out. If you look in your home directory there is a directory named .vagrant.d where all of your vagrant settings are stored. Inside of this is a directory name boxes which contains a copy of the VM that vagrant downloads from it's website before it's imported into VirtualBox.

It turns out another important part of the Vagrantfile config is actually this line:

config.vm.box = "precise32"

It's what determines what directory vagrant looks in for the base VM. If we either delete the corresponding directory or change this line in our Vagrantfile vagrant will be forced to download the new precise64 box and use it instead. In this article, I'm going to change the config.vm.box setting to read "precise64" and if I make this change and vagrant destroy and vagrant up again I'm treated with the correct version of Ubuntu.

Hopefully, this little article will save someone else a lot of headaches.