Drupal Development with Drupal VM

Posted on: Sun, 11/10/2019 - 10:56 By: Arun AK

Drupal VM is a virtual machine built with Ansible. Drupal VM makes Drupal development easy and helps the developer to start working on a fully configured environment in his local computer.

Drupal VM comes with following on an Ubuntu 16.04 (by default):

Let us see how to set up Drupal VM with Vanilla Drupal.

Softwares Required

  1. Vagrant
  2. VirtualBox

Step 1: Create a new project using composer. (Refer: Drupal 8 development with Composer and Drush for more information.)

Step 2: Then in terminal navigate to yor project root folder and add Drupal VM using composer as below.

composer install geerlingguy/drupal-vm

Step 3: Copy default.config.yml file from vendor/geerlingguy/drupal-vm/ to your project root folder.

vendor/geerlingguy/drupal-vm/default.config.yml to box/config.yml

Update following values:

vagrant_hostname: local.yourwebsite.com
vagrant_machine_name: yourwebsite

Step 4: Create a Vagrant file and place it the root directory of your project.

Add the following content in the Vagrant file.

# The absolute path to the root directory of the project. Both Drupal VM and
# the config file need to be contained within this path.

# The relative path from the project root to the config directory where you
# placed your config.yml file.

# The relative path from the project root to the directory where Drupal VM is located.
ENV['DRUPALVM_DIR'] = "vendor/geerlingguy/drupal-vm"

# Load the real Vagrantfile
load "#{__dir__}/#{ENV['DRUPALVM_DIR']}/Vagrantfile"

Step 5: Then run the command vagrant up.
It will initiate the setup process. At the end of the process, you could see the drupal-vm details for your website as below:

==> yourwebsite: Machine 'yourwebsite' has a post `vagrant up` message. This is a message
==> yourwebsite: from the creator of the Vagrantfile, and not from Vagrant itself:
==> yourwebsite:
==> yourwebsite: Your Drupal VM Vagrant box is ready to use!
==> yourwebsite: * Visit the dashboard for an overview of your site: http://dashboard.local.yourwebsite.com (or
==> yourwebsite: * You can SSH into your machine with `vagrant ssh`.
==> yourwebsite: * Find out more in the Drupal VM documentation at http://docs.drupalvm.com

Once you open dashboard(http://dashboard.local.yourwebsite.com) you could see the list of websites and databases. Your local site can be accessed using http://local.yourwebsite.com