I've never set up a vagrant box before and I'm on Skype with @ryanburnette who is guiding me...

Install VirtualBox

curl -fSL http://download.virtualbox.org/virtualbox/4.3.20/VirtualBox-4.3.20-96996-OSX.dmg -o /tmp/virtualbox.dmg
open /tmp/virtualbox.dmg
sudo /usr/sbin/installer -pkg /Volumes/VirtualBox/VirtualBox.pkg -target /

# BTW, if you rename the extpack file it won't install. Weird, right?
curl -fSL http://download.virtualbox.org/virtualbox/4.3.20/Oracle_VM_VirtualBox_Extension_Pack-4.3.20-96996.vbox-extpack -o /tmp/Oracle_VM_VirtualBox_Extension_Pack-4.3.20-96996.vbox-extpack
sudo VBoxManage extpack install /tmp/Oracle_VM_VirtualBox_Extension_Pack-4.3.20-96996.vbox-extpack

Install Vagrant

curl -fSL https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.1.dmg -o /tmp/vagrant.dmg
hdiutil attach /tmp/vagrant.dmg
sudo /usr/sbin/installer -pkg /Volumes/Vagrant/Vagrant.pkg -target /
hdiutil detach /Volumes/Vagrant

Create your first Vagrantfile and install

When you're in your vagrant directory you're in the context of that file.

mkdir -p ~/Code/vagrantbuntu
pushd ~/Code/vagrantbuntu
vim Vagrantfile


Vagrant.configure(2) do |config|
  config.vm.box = 'ubuntu/trusty64'
  config.vm.hostname = 'blog-dev'
  config.vm.network :forwarded_port, guest: 80, host: 8080
  config.vm.network :forwarded_port, guest: 443, host: 8443
  config.vm.provider :virtualbox do |vb|
    vb.customize ['modifyvm', :id, '--memory', '256']
  config.vm.synced_folder './home', '/home/vagrant/vagrant', owner: 'vagrant', group: 'vagrant', mount_options: ['dmode=755','fmode=755']
  config.vm.synced_folder './vagrant', '/vagrant', owner: 'vagrant', group: 'vagrant', mount_options: ['dmode=755','fmode=755']
mkdir home vagrant
vagrant up

Access your box

vagrant ssh 

Shutting down

vagrant halt

Next Steps


I like to copy .gitconfig, .jshint, .vim/, .vimrc, and a few keys from .ssh/.

If you're going to share projects between your local system and the vagrant box, set git config core.fileMode false on the vagrant box.


You'll notice that I alloted 256mb of RAM to the vagrant box. For my purposes that will usually be adequate, but occasionally (if I need to compile something from source on the box or use npm for large packages like 'bower' or 'yo') it won't, so I'm also creating a swapfile for those short, brief occasions.

curl https://gist.githubusercontent.com/coolaj86/15a42f09a4d88e03906a/raw/create-swap.sh -o /tmp/create-swap.sh
bash /tmp/create-swap.sh 384


sudo apt-add-repository ppa:fish-shell/release-2; \
sudo apt-get update; \
sudo apt-get install -y fish

# Make fish my default shell
sudo chsh -s $(which fish) $(whoami)

Node + Dev Tools

curl -fsSL bit.ly/easy-install-node | bash


Possible Errors

Extension pack name mismatch

If you rename the awkwardly long Oracle_VM_VirtualBox_Extension_Pack-4.3.20-96996.vbox-extpack to something shorter, it fails to install.

VBoxManage: error: Extension pack name mismatch between the downloaded file and the XML inside it (xml='Oracle VM VirtualBox Extension Pack' file='')
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component ExtPackFile, interface IExtPackFile, callee nsISupports
VBoxManage: error: Context: "Install(fReplace, NULL, ptrProgress.asOutParam())" at line 1141 of file VBoxManageMisc.cpp



set -e

# size of swapfile in megabytes
if [ -n "$1" ]; then

# does the swap file already exist?
SWAPFILE=$(grep "swapfile" /etc/fstab || echo -n "")

# if not then create it
if [ -z "$SWAPFILE" ]; then
  echo 'swapfile not found. Adding swapfile.'
  sudo bash -c "fallocate -l ${swapsize}M /swapfile"
  sudo chmod 600 /swapfile
  sudo mkswap /swapfile
  sudo swapon /swapfile
  sudo bash -c "echo '/swapfile none swap defaults 0 0' >> /etc/fstab"
  echo 'swapfile found. No changes made.'

# output results to terminal
cat /proc/swaps
cat /proc/meminfo | grep Swap

# sudo swapoff /swapfile
# sudo rm /swapfile
# sudo vim /etc/fstab

ruby script thing for rvm

curl -L --create-dirs -o ~/.config/fish/functions/rvm.fish https://raw.github.com/lunks/fish-nuggets/master/functions/rvm.fish
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

By AJ ONeal

If you loved this and want more like it, sign up!

Did I make your day?
Buy me a coffeeBuy me a coffee  

(you can learn about the bigger picture I'm working towards on my patreon page )



Buy me a coffeeBuy me a coffee

  73% of Goal Reached

Want more like this?