User login

Drupal in a virtual machine cheat sheet

This cheatsheet presumes you're already set up with VirtualBox and Vagrant, configured for Drupal. (Agaric has our own base box to have a head start on setting up for this purpose, but some of the magic is in the Vagrantfile stored with our projects.)

In a terminal, go to the directory holding your Vagrantfile and your project code. Then the fun begins.

vagrant up

to start the virtual machine.

vagrant ssh

To go inside the virtual machine. Once inside the VM, you'll usually be using lots of Drush commands like:

drush cc all

to clear cache, or

drush dis dblog

to disable the database logging module for Drupal's watchdog. Because

tail -f /var/log/syslog

will show you all the notices and errors from your Drupal site, as they occur.

(Hint: You can open more than one console into your virtual machine; just vagrant ssh from a new console from your host machine, while at your project directory.)

Most files that you'll care about are shared between the virtual machine and your host machine. These are the files in your project folder on your host machine (where the Vagrantfile lives) and in /vagrant from the virtual machine.

Some files you may need to edit on the virtual machine, such as Drush aliases:

vi ~/.drush/test.aliases.drushrc.php

$command_specific['rsync'] = array('mode' => 'rlptz');

(That can help the file sync command.)


A Drupal multisite, if you are unlucky enough to be dealing with one, means some extra work: mostly, use drush aliases for everything.

drush -y sql-sync @test.nichq-coiin
drush -y rsync @test.nichq-coiin:%files


If someone updates requirements in the virtual machine, do this from your host:

git pull
vagrant provision

If someone updates Drupal modules (core, contributed, or custom), git pull and then do this from within the virtual machine

drush -y updb

Or for multisite, something like drush @test.nichq-coiin -y updb


Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.