Deep Impact Header picture
Home » Tutorials » Drupal on a Virtual Machine with Vagrant

Drupal on a Virtual Machine with Vagrant

There are several ways to develop local Drupal sites:

This article gives you step by step instructions for installing a single Drupal site on a virtual Linux machine using Vagrant.

Before you start

If you have implemented virtualisation before (e.g. VirtualBox), you can skip these next steps and continue with the installation instructions.

  • Download and install the free version of Speccy: https://www.piriform.com/speccy/download
  • Open Speccy and in the left column, click CPU
  • Check if your BIOS supports virtualization, and if it's enabled
    speccy screenshot
  • If yes, continue with the installation instructions
  • If virtualization is supported, but not activated, you'll have to active this option in your BIOS settings. You can find this setting under "Advanced CPU options", "Security", or something similar.
  • If virtualization is not supported, you can quit this tutorial and do something interesting with your life.

 

Installation

  • Install VirtualBox: https://www.virtualbox.org/wiki/Downloads
  • Install Vagrant: http://www.vagrantup.com/downloads.html
    preferably in your root folder, e.g. C:\Vagrant
  • Download the Drupal zip file: https://github.com/geerlingguy/drupal-vm/archive/master.zip
  • Unzip the file
  • In this folder, make copies of
    • example.drupal.make.yml
    • example.config.yml
  • Rename these copies to:
    • drupal.make.yml
    • config.yml
  • Make a folder for your Drupal site somewhere on your computer
  • Copy the location of this folder to line 24 of config.yml (e.g. - local_path: F:/myDrupalSite). Do this in an editor like Notepad, Notepad++, Sublime, Brackets, etc. Do not use Word or similar text processing applications.
    • Attention Windows users! Windows uses backslashes in paths (e.g. F:\myDrupalSite). As we are using a linux server, you'll have to change the backslashes to forward slashes (e.g. F:/myDrupalSite)
  • Start VirtualBox
  • Start vagrant (the .exe is in C:\Vagrant\bin)
  • Open the Command Prompt (Start > type cmd)
  • Navigate to the drupal-vm-master folder, e.g.
    Command prompt screenshot
  • Type 'vagrant up' in the Command Prompt (without the quotes) and press enter.
  • Wait until all files have been downloaded and installed (virtual machine, ubuntu, apache, varnish…). This can take a while.
  • After the installation, a virtual Linux machine will run in the background
  • There are 2 ways to access your Drupal site via your web browser:
    • Via the IP address: 192.168.88.88
    • Via drupalvm.dev. You have to edit your hosts file for this (see below)

The next time you want to use this installation, you only have to open VirtualBox and start the drupalvm machine. When the drupalvm machine is running, you can start using Drupal in your favorite browser using 1 of the 2 addresses from step 16.

Adjusting the Hosts file

  • Navigate to C:\Windows\System32\drivers\etc
  • Copy the Hosts file to your desktop
  • At the bottom, add the following line: 192.168.88.88 drupalvm.dev
  • Save the file
  • Copy the file to C:\Windows\System32\drivers\etc and overwrite the original Hosts file

 

Download these instructions (Dutch version):
Download PDF