Backend and Infrastructure

Installing Vagrant and VirtualBox

This page is archived

We're keeping this page up as a courtesy to folks who may need to refer to old instructions. We don't plan to update this page.

Alternate resources

Sprout Video

Note: This video is outdated. The following command:

$ vagrant init precise32 has download problems if you try it. Try this instead:

$ vagrant init hashicorp/precise64

(The written instructions below contain this update.)

Before we jump into the automation of creating a new developer environment, we need to get the building blocks we'll be working with. You will need to download and install both Vagrant and VirtualBox.

Lesson Outcomes

By the end of this lesson, you will be able to install Vagrant and VirtualBox on a host platform of OSX, or Windows; and create and destroy a Vagrant instance.

Lesson Summary

  1. Install VirtualBox
  2. Install Vagrant
  3. Create a new directory for your configuration scripts. e.g. Websites, or Work-environments. This folder will not contain the VirtualBox binary files, just the Vagrant configuration scripts.
  4. From the command line, run the following commands:
    • $ vagrant init hashicorp/precise64
    • $ vagrant up
    • $ vagrant ssh
      Note: this command will not work for Windows. You will need to use PuTTY to log into your machine. This is covered in the bonus lesson.
  5. To return to your host machine, run the command:
    • $ exit
  6. To destroy the VM and remove the binary disk image:
    • $ vagrant destroy
      This command must be run from the directory which contains the Vagrantfile for the box you wish to destroy. It will not remove any of your configuration files. To recreate the machine, use the commands in step 4.

Troubleshooting and Gotchas

  • The lessons were recorded using Vagrant 1.4.3, and VirtualBox 4.3.6.
  • There are some gotchas to be aware of: Linux and Windows may need a reboot because of the kernel drivers being added.
  • Sometimes upgrades don't work, and re-installing is your best bet. If you have automatic software updates turned on, and Vagrant stops working for you without an obvious reason, try removing everything and re-install using the instructions in this lesson. Removing Vagrant and VirtualBox are covered in one of the extra lessons.

Additional resources

VirtualBox Downloads
Vagrant Downloads

Note: another common tool for creating development environments today is Docker, which is becoming very popular with Drupal (and other) developers. Take a look at our Drupal Development with Docker series to learn more.