Experimental Project

This is a sandbox project, which contains experimental code for developer use only.

Some Forks Are Used For Good, Not Evil

This is a fork of the Drupal Vagrant project. But this fork isn't born of ill will. Rather, it is designed to provide recipes specific to the book Learning Multi-Site Drupal.

This will create a full Ubuntu Linux server running as a virtual machine on your computer, preconfigured for running a Drupal multi-site (lots of sites on one installation of Drupal).

Prerequisites

Before installing, you will need to do the following:

  • Install VirtualBox. You will need a recent (>4.08) version.
  • Install Vagrant.
  • Get this project from Drupal.org (Instructions). You will need Git for this step.

Installation

Once you have VirtualBox, Vagrant, and this project, you are ready to start the installation process.

  1. At the command line, go into the directory for this project: $ cd multisite_vagrant/
  2. If you haven't done so in the past, get the base Ubuntu Lucid image for vagrant: vagrant box add base http://files.vagrantup.com/lucid32.box
  3. Tell Vagrant to build you a shiny new virtual machine: vagrant up

By the time you've freshened up your coffee (or grabbed an Oreo milkshake), Vagrant should have downloaded, installed, and configured a new box for you. It will have: A minimal version of Ubuntu Linux, Apache 2.2, MySQL 5.1, PHP 5.3, Drupal 7 and some basic modules. It will also have some useful debugging tools like Xdebug and xhprof. Memcache and Varnish can be "turned on" with just a tiny bit of configuring.

Accessing Your Awesome New Server

Your new virtual machine lives on your local host, and you can access it in the following ways:

Files

Some of the files on your virtual host are transparently shared with your host computer. If you are in the multisite_vagrant directory, all of the data you see there is shared with your virtual machine. A change to one of these files here will be immediately available to the virtual machine.

SSH

Issue this command from your terminal: $ vagrant ssh. This will connect you to your new Drupal server. Go to /vagrant/public to see the files directory that is shared with your local host. The rest of the stuff is stored in its normal Linuxy place.

(Did I mention that Drush is installed for you?)

Web

Assuming you installed the site exactly as it is (without editing the Vagrantfile), this virtual host is configured to listen on the address 33.33.33.10 (or sometimes 33.33.33.11 -- this makes it easier to run regular Drupal Vagrant at the same time) for three domain names:

  • books.local
  • cooks.local
  • looks.local

Lest you be perplexed about the names, these are the names used in the book.

You will want to edit your local hosts file, adding this to the bottom:

33.33.33.11 books.local cooks.local looks.local

Customizing

You should definitely tinker around with this thing. Here's the 30 second tour:

  1. Vagrantfile is your friend. Read it. Try stuff. It is the master configuration file.
  2. Want different sites than books, cooks, and looks? Just edit :localhost_aliases in the Vagrantfile. Then you will need to run this command to rebuild your virtual machine: vagrant provision. That command is very helpful.
  3. When you build a box, Vagrant runs one or more roles. The roles are configured in the Vagrantfile and stored in the roles/ directory. By default, this module runs the role called drupal_multisite_dev
  4. Vagrant runs this thing called chef, which is a piece of software used for build management and delivery. Appropriately, chef uses recipes to figure out what it's doing. These are stored in cookbooks, and they are called from roles (the same roles I mentioned before). You'll need to learn about some of this stuff if you want to tinker a lot. The documentation at http://vagrantup.com is very good.
  5. chef.add_recipe("drupal::install_multisite") Did you see this line in your Vagrantfile? Comment it out and Drupal won't be installed. You'll have a server all ready, and you can fiddle with it however you want. Or you can edit the recipe itself. It lives in cookbooks/drupal-cookbooks/drupal/recipes/install_multisite.rb. Also take a look at the example.rb recipe (from Drupal Vagrant) to see another way of building out a site.
  6. DO IT AGAIN!: vagrant destroy nukes your virtual machine. vagrant up rebuilds it again from scratch. It's fun. I highly recommend it.
  7. Or you can stop your VM exactly where it is, and start it up again later: vagrant suspend, grab milkshake, come back, vagrant resume.

And a word to the wise: If you're doing something important, DON'T put the only copy inside of your VM. At least keep another copy locally.

Ack

This project is just a fork of the main Drupal Vagrant project. It's forked not because I'm trying to do anything better, but because I wanted to provide a stable build as a companion for the MultiSite book.

If you do awesome stuff with this and want to contribute it back, you're welcome to send it my way. You might also consider working on the real Drupal Vagrant project. Many people will thank you for it.

Yes, Vagrant uses Ruby. No, it doesn't use PHP.

Project Information