Note this uses PHP 5.3 so that Drupal 6 sites can be used with it, Drupal 7 can also run on PHP 5.3 but later versions are possible as well. It would be possible to update the script to use 5.4 if required, I'll get back here on that with the steps.

Credit: These are setups crafted by Mike Bell (@mikebell) co-organiser of DrupalCamp NW in the United Kingdom.
https://github.com/mikebell/drupaldev-apache

Quick summary - this is the best Vagrant setup I have used so far owing to its stability and out-of-the-box ease of use.

There is also an nginx version of this setup - and Mike Bell is investing more time into that. However this drupaldev-apache setup works very well - it's robust and the steps for setting it up are predictable and consistent as I've used it on at least 5 different machines now.

Duration:

  • Initially: 30mins - 1 hour (depending on internet connection speed for downloading Vagrant box and for familiarising with concepts - but it is step by step - shouldn't have to think or make any decisions, shouldn't be any ambiguity)
  • Thereafter: 5 mins approx! The initial setup really does pay off and you get an environment that more closely (or even exactly) matches your production live environment

Steps:

Install

  1. Clone Me - Choose a directory on your local development machine, then issue the git clone command for this repo
    git clone http://github.com/mikebell/drupaldev-apache
    cd drupaldev-apache
  2. mkdir sites
  3. cp manifests/example.pp manifests/devsites.pp
    Amend manifests/devsites.pp as required to desired server/virtualhost name and db details
    What this means that here in devsites.pp you can configure as many local sites as you require. You can add more sites later, by updating the file with these - and after doing this update issue vagrant provision at your terminal / command line console window when in your vagrant folder. This is useful if you are working on multiple projects (e.g. several clients and your own projects).

    For each site you'll need and entry in your machine's hosts file, i.e. /etc/hosts/ on Mac/Linux, hosts is in System32 in Windows.

    Example setup snippet for devsites.pp

    # Define your sites here
    $sites = [
        'example',
        'example1',
        'example2',
    ]

    Each local site has its own local web address (and folder on the server to contain the Drupal code), MYSQL database, database user -- all of these are setup by just adding the site name to the list in devsites.pp

    The Virtual Machine's IP address is set to 33.33.33.10.
    Therefore, for each of the sites in your devsites.pp above, you'll need a corresponding entry in your machines hosts file so that, on entering example.drupal.dev or example1.drupal.dev - your browser is directed to your local site. /etc/hosts file is the location of the hosts file on Mac and Linux/Unix machines. For Windows the hosts file is located at the path %SystemRoot%\system32\drivers\etc\hosts - which is typically C:Windows\system32\drivers\etc\hosts
    (For more information about editing the hosts file, see the end of this doc)

    Add something like the following to your hosts file for each site's local development domain:

    33.33.33.10 example.drupal.dev
    33.33.33.10 example1.drupal.dev
    33.33.33.10 example2.drupal.dev
    # etc...
    
  4. vagrant up

    The first time this is done, there are 3 stages:

    stage 1) it can take around 20 to 30mins as it downloads the Vagrant box file - this is a large file and is equivalent to a .iso CD/DVD install image for your Operating System - i.e. Linux.

    stage 2) This is followed by one of setup which is equivalent to the install process you'd do if you put the disk in your machine and booted with it.

    stage 3) Then there is the usual booting process which is what would happen when you boot the machine

    (to shut the machine down, ensure you're still in the vagrant folder and issue vagrant halt

    Thereafter, subsequent vagrant up commands, only stage 3) happens - just the boot

Setting up your hosts file for local development domains

In your /etc/hosts file, add an entry for each of the sites you setup in devsites.pp above

To edit the hosts (Mac/Linux) file you'll need either root access or have an account with sufficient admin privileges (e.g. on mac an Admin) to be a sudo-er
e.g.
su root
(enter password)
vi /etc/hosts
(to edit hosts)

or

sudo vi /etc/hosts
(enter password - your account's usual password)

/etc/hosts file is the location of the hosts file on Mac and Linux/Unix machines. For Windows the hosts file is located at the path %SystemRoot%\system32\drivers\etc\hosts - which is typically C:Windows\system32\drivers\etc\hosts
(here, you may need Windows user Admin rights depending on how your system is setup).

VM Info

Default port 33.33.33.10
Sites built as *.drupal.dev - don't forget to edit your hosts file to be able to use the URLs in your browser, e.g. mysite.drupal.dev (or use dnsmasq)
Ubuntu 12.04 (this is a stable and well tested Long Term Support edition of Ubuntu)
From the github read me:

DrupalDev apache
Build Status

Modified vagrant config from puphpet. Supports Drupal 6/7/8. Built in Drush and Composer.

DrupalDev Nginx

Please consider using https://github.com/mikebell/drupaldev-nginx as an alternative as drupaldev-apache is "barely maintained and various issues means that updating it has become impossible. If anyone wants to maintain this then please fork."

Tools

Removed xhprof it doesn't work in this config
Easier handling of vhosts and dbs (see example.pp)
Drush
Compass
Omega 4 Gems included as standard
APC / Memcache
Mailcatcher - access example.drupal.dev:1080

Dependencies

Xcode with Command Line Tools installed
Vagrant - http://www.vagrantup.com/
VirtualBox - https://www.virtualbox.org/