Middleman with Vagrant 17 February 2014

Recently, I was trying to start working on my website again. I had created it using Middleman. As I was trying to set it up I ran into a couple of issues, mainly due ruby issues on Windows.

So I decided to use Vagrant to create a reference environment for the project, and it couldn't have been easier.


  • Install VirtualBox or any provider which Vagrant supports)
  • Install Vagrant
  • A basic Middleman project, see here

Setup your Vagrant VM

Create the directory for your project and open a command prompt to that path.

Run the following command to generate a Vagrantfile:

vagrant init

A Vagrantfile is basically a configuration file for your Vagrant VM. Mine ends up looking something like this:

# -*- mode: ruby -*-
# vi: set ft=ruby :


Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "precise64"
  config.vm.box_url = "http://files.vagrantup.com/precise64.box"
  config.vm.network :forwarded_port, guest: 4567, host: 4567

Obviously, you can customize this to your needs

Configure provisioning

Next, we'll setup a provisioning script so we can tell the VM to install packages. We're going to use the shell provisioner for this tutorial. It's the simplest provisioner to use, and is easy to wrap your head around if it's your first time using Vagrant. Basically, it runs a shell script as root during the provisioning process.

Create the file bootstrap.sh and paste the following into it:

#!/usr/bin/env bash

apt-get update
apt-get install -y build-essential ruby1.9.3 libxslt1-dev libxml2-dev
gem install bundler

This will install a few required packages from apt as well as the bundler gem (system-wide).

To tell Vagrant to use the script for provisioning add the following line to your Vagrantfile, right before the end keyword:

config.vm.provision :shell, :path => "bootstrap.sh"

Start the VM

Issue the following command to build, provision and start the VM.

vagrant up

SSH into the VM

If you are on OSX or Linux, issue the following command to SSH into the VM:

vagrant ssh

If you're on Windows you'll need to install PuTTY or something like it in order to SSH into the VM. Vagrant's private key is located in your home directory under .vagrant.d/insecure_private_key.

Install gems

Once you're SSH'd into the machine, move to Vagrant's shared folder

cd /vagrant

Now you'll use bundler to install the required gems:

bundle install

Start Middleman

Now you should be able to run middleman to serve the site


To view your site open up http://localhost:4567 on your host machine. Additional site information can be found at http://localhost:4567/__middleman.

Site Update 13 January 2013

Hello! I finally put the new site live, as I wanted to make some kind of progress tonight. There's still not much here at the moment, but I'm working on it. It'll be easier for me to start putting more work into this now that the holidays are over.

I've been putting time into learning some new things lately, so I'll likely have some things to write about as I work through everything. Mostly I've been working on getting back into Ruby on Rails and learning about Continuous Delivery. One of these will likely be the topic of a longer-form post in the near future. Possibly SASS/Compass/susy too, since they're neat.

I promise the theme will start to get better soon.

First Post 3 December 2012

I redid the site again, this time using Middleman. There was too much extra garbage enabled by default in Octopress for my taste.

More content coming soon!