Varying Vagrant Vagrants Setup

By: Ryan Kienstra on: November 14, 2014  in: Programming

As a development environment for WordPress, Varying Vagrant Vagrants has many tools. It also has the latest branches of the WordPress core.

To get started, install VirtualBox and Vagrant if you need to. Even if your host machine runs Ubuntu, it’s best to install them from their websites. Ubuntu’s apt-get doesn’t have the most recent version of Vagrant.

If you’d like, execute this script in the directory where you want “Varying Vagrant Vagrants”. You’ll have an option to install an Emacs editor.

#!/bin/bash

echo “Set up Emacs editor and bash aliases in Vagrant? y/n”
read do_install_emacs 
vagrant plugin install vagrant-hostsupdater
vagrant plugin install vagrant-triggers
git clone git://github.com/Varying-Vagrant-Vagrants/VVV.git vagrant-local
cd vagrant-local
vagrant up

if [ $do_install_emacs = 'y'  ];
   	then vagrant ssh
	cd $HOME
	git clone https://github.com/kienstra/setup.git
  	./setup/setup.sh
  	echo “Type ‘em ~/.bashrc_custom’ to edit your bash aliases, or ‘em ~/emacs.d/init.el’ to edit your Emacs shortcuts”;
fi;

echo “Enjoy your new Vagrant install. See your sites at ‘http://vvv.dev'.”
echo “Pause the machine with ‘vagrant suspend’, or shut it down with ‘vagrant halt’.”

This may take 10 to 20 minutes. You’ll probably be prompted for a password so it can edit the hosts file.

Then, enter vvv.dev in your browser:

Vagrant Site

You can see the different versions of WordPress. For example, local.wordpress-trunk.dev will show you the trunk. You can edit in the /srv/www/wordpress-trunk/wp-content directory of the Vagrant install.

The setup script above will start the machine for you. But to start it on you own, enter vagrant up

Vagrant up

vagrant suspend pauses the machine, while vagrant halt shuts it down. Both will save its state.

You can ssh into the machine with vagrant ssh

If you chose to install the Emacs editor, you can edit its shortcuts by typing emacs ~/.emacs.d/init.el
Emacs shortcuts

You can still edit files on your host machine, though.

TroubleshootingVagrant browser error

If your browser shows an error when you enter vvv.dev, there’s probably a problem with your hosts file.

The vagrant-hostsupdater plugin should update your hosts file. If you haven’t installed it, cd to your vagrant directory, and type vagrant plugin install vagrant-hostsupdater.

If that doesn’t work, enter 192.168.50.4 in your browser, or curl 192.168.50.4 in your terminal.

The next step is to check your hosts file. In OSX, type emacs /private/etc/hosts, and in Ubuntu systems, type emacs /etc/hosts.

You should see 192.168.50.4:

Hosts file

If you don’t see that IP address, add this line to the file:

192.168.50.4 vvv.dev local.wordpress.dev local.wordpress-trunk.dev src.wordpress-develop.dev build.wordpress-develop.dev

You’ll have to edit this file as root, so use sudo emacs /private/etc/hosts on OSX.

This is a complex system, but its features are well worth the setup.

  • This field is for validation purposes and should be left unchanged.

Leave a comment

Get Free Updates

  • This field is for validation purposes and should be left unchanged.