Tools for setting up an environment
One of the initial hurdles to getting started with Drupal is a local development environment. This recipe will cover how to set up the DrupalVM project by Jeff Geerling. DrupalVM is a VirtualBox virtual machine run through Vagrant, provisioned and configured with Ansible. It will set up all of your services and build a Drupal installation for you.
Luckily, you will only need to have VirtualBox and Vagrant installed on your machine, and DrupalVM works on Windows, macOS X, and Linux.
Getting ready
To get started, you will need to install the two dependencies required for DrupalVM:
- VirtualBox: https://www.virtualbox.org/wiki/Downloads
- Vagrant: http://www.vagrantup.com/downloads.html
How to do it...
Let's set up the DrupalVM project by Jeff Geerling by following these steps:
- Download the DrupalVM archive from https://github.com/geerlingguy/drupal-vm/archive/master.zip.
- Extract the archive and place the project in the directory of your choice.
- Copy
example.drupal.make.yml
todrupal.make.yml
. - Copy
default.config.yml
toconfig.yml
.
- Edit
config.yml
and modify thelocal_path
setting to be the directory where you've placed the DrupalVM project. This will be synchronized into the virtual machine:
vagrant_synced_folders: local_path: /path/to/drupalvm destination: /var/www type: nfs create: true
- Open a terminal and navigate to the directory where you have placed the DrupalVM project.
- Enter the
vagrant up
command to tell Vagrant to build the virtual machine and begin the provisioning process. - While this process is ongoing, modify your host file to provide easy access to the development site. Add the
192.168.88.88 drupalvm.dev
line to your host file. - Open your browser and access http://www.drupalvm.com/.
- Log in to your Drupal site with the username
admin
and passwordadmin
.
How it works...
DrupalVM is a development project that utilizes the Vagrant tool to create a VirtualBox virtual machine. Vagrant is configured through the project's Vagrantfile
. Vagrant then uses Ansible--an open source IT automation platform--to install Apache, PHP, MySQL, and other services on the virtual machine.
The config.yml
file has been set up to provide a simple way to customize variables for the virtual machine and provisioning process. It also uses Drush to create and install a Drupal 8 site, or whatever components are specified in drupal.make.yml
. This file is a Drush make
file, which contains a definition for Drupal core by default and can be modified to include other contributed projects.
The vagrant up
command tells Vagrant to either launch an existing virtual machine or create one anew in a headless manner. When Vagrant creates a new virtual machine, it triggers the provisioning process. In this instance, Ansible will read the provisioning/playbook.yml
file and follow each step to create the final virtual machine. The only files that need to be modified, however, are the config.yml
and drupal.make.yml
files.
There's more...
The topic of automating and streamlining a local environment is quite popular right now with quite a few different options. If you are not comfortable with using Vagrant, there are a few other options that provide a server installation and Drupal.
Acquia Dev Desktop
Acquia Dev Desktop is developed by Acquia and can be found at https://docs.acquia.com/dev-desktop2. It is an automated environment installer for Windows and Mac. It is a xAMP stack (or DAMP stack) installer that provides a full Drupal-specific stack that includes Apache, MySQL, and PHP. The Dev Desktop application allows you to create a regular Drupal installation or select from a distribution.
XAMPP + Bitnami
XAMPP - Apache + MySQL + PHP + Perl - is a cross-platform environment installation. XAMPP is an open source project from Apache Friends. XAMPP has partnered with Bitnami (https://bitnami.com/) to provide free all-in-one installations for common applications, including Drupal 8. You can download XAMPP at https://www.apachefriends.org/download.html.
Kalabox
Kalabox is developed by the Kalamuna group and intends to be a robust workflow solution for Drupal development. Kalabox is cross-platform compatible, allowing you to easily work on Windows machines. It is based on the command line and provides application binaries for you to install. You can learn more about Kalabox at http://www.kalamuna.com/products/kalabox/.
See also
- Refer to Chapter 13, The Drupal CLI, for information on makefiles.
- DrupalVM documentation http://docs.drupalvm.com/en/latest/.
- Refer to Drupal.org community documentation on local environment setup at https://www.drupal.org/node/157602.