Drupal Development with Vagrant and VDD on Windows: Getting Started

Vagrant Drupal Development

For a long time, I was working with OpenServer, a WAMP stack, which is actually good for a beginner. As my understanding of development details grew, the limitations and incompatibilities of Windows were becoming more and more annoying. At some point, we all have to switch to Linux, and the sooner we dare the better.

I have tried several different Vagrant based configurations found on the web but all of them had their inconveniences and flaws. It was a lucky spring night, when far after midnight I came across the VDD project, tried it and found that it is exactly what I was looking for. In this post, I will try to describe how to get Drupal development environment up and running within an hour.

After completing the installation, you will have:

  1. Virtual server running Ubuntu 12.04 LTS
  2. LAMP Stack
  3. PhpMyAdmin
  4. Drush (with automatic aliases and Drupal 8 support)
  5. GIT
  6. Xdebug, Webgrind (configured and ready to use)
  7. Mailcatcher

Setting up Vagrant Drupal Development

It takes a while to install all this software manually, especially with little Linux experience. Using VDD, you need to make only few steps.

1. Install Oracle VM VirtualBox – download link.

Oracle VM VirtualBox is a piece of free virtualization software, which is necessary to run a virtual Linux machine.

2. Install Vagrant – download link

Briefly, Vagrant allows you to get virtual servers running by configuration files (which contain Linux version, a list of preinstalled software, etc).

3. Download Vagrant Drupal Development and extract it into a new folder – download link

All the important options are kept in the config.json file:

"ip": "" - Defines the IP address your virtual server will be accessible at. You can set any address within 192.168.xxx.xxx range.

"memory": "1024" - The amount of RAM available for this virtual machine. With my total 8 GB RAM, I usually give it 2048 Mb.

"synced_folders": [ … ]Addresses to the folders that will be used for keeping Drupal files on your host (Windows) and guest (Linux) machines. Virtualbox synced folders are annoyingly slow. How to improve it – later on.

Drupal and Webserver configuration is also available as a JSON object:

"drupal7": {    
// Internal name of the website. 
//A database for this website will also have this name. 
  "account_name": "root",
 // Drupal admin account login (this and further Drupal options 
//will work only if Drupal gets installed with the Drush site-install command)
  "account_pass": "root", 
// Drupal admin account password
  "account_mail": "box@example.com",
// Drupal admin account email
  "site_name": "Drupal 7", 
// Guess what? Initial site name. 
  "site_mail": "box@example.com",
  "vhost": {
    "document_root": "drupal7", 
// Folder to keep site’s files in. 
// In this case, it will be ‘/var/www/drupal7’
    "url": "drupal7.dev", 
// External URL for this website. 
// Do not forget to map it to the IP address above ( in your Windows hosts file.
    "alias": ["ww.w.drupal7.dev"] 
// Another URL the website will be available at.

This is much self-explanatory. If you need to add a website to this server, you simply copy this set of configurations, make corrections, run vagrant provision and once it’s done, you’ll have the server ready (with properly set up apache and new database created) for your new project.

To start the installation go to your VDD folder in your terminal and type:

vagrant up

You can use Git Bash terminal, your IDE terminal or whatever Windows terminal you prefer. By the way, PhpStorm has a great Vagrant support inside.

The command starts the installation process. If you’re doing it for the first time, it is going to take a while as it has to download the entire Linux distribution. The amount of time varies and depends mostly on your internet connection speed and hardware.

Once it is done, you can access your new Linux server via SSH by one of the following ways:

  • Typing vagrant ssh from your VDD folder
  • Connecting to the chosen IP address ( with username vagrant and password vagrant

In order to connect to the database with any Windows software (for instance, Navicat Premium), use SSH tunnel option and username root and password root as MySQL credentials.

And, that’s it. With very few efforts, you have a fully functional virtual Linux machine with everything included for comfortable Drupal development.

Getting rid of Synced Folders

As mentioned, Virtual Box synced folders are very slow, and after a while waiting for another page to load becomes annoying. But no worries, there are many ways to do your job without them.

The first thing I did was changing synced_folders in config.json to an empty array:

"synced_folders": []

And running

vagrant provision

This console command makes changes to the server according to the changes in config.json. So every time you need to add a new website or make any settings corrections, run vagrant provision. Changes wouldn’t apply on their own.

I tried to use Sshfg Manager as a synchronizing tool (recommended in the official VDD documentation). Sshfg Manager creates a new drive on Windows machine, which leads to a certain folder on your Linux machine, with two-side synchronization. It worked well however was making my Windows crash quite often. Eventually I uninstalled it in flavor to dkLab RealSync (read the description on how to set it up). This fast and light-weighted script monitors file changes and updates them on the guest machine via SSH. The downside is that it does not monitor changes on the Linux, so every time you install a new module with Drush and want to inspect its files, you have to download them manually.

Note that while doing vagrant provision, you might get an error about missing synced folders. I solved it by deleting the \path to vdd directory\.vagrant\machines\default\virtualbox\synced_folders file. It doesn’t seem to break anything but doesn’t seem right, either. If you happen to know a better solution, please share it in comments.

Without synced folders, Drupal works fast – much faster compared to OpenServer.

Hope this article was a useful introduction to Drupal development with VDD.

See also: