Installing and Using VVV
What VVV Is
Varying Vagrant Vagrants (VVV) is a collection of technologies designed to provide a standardized environment for WordPress development.
Specifically, VVV makes use of Vagrant to provision (setup) a virtual machine and install WordPress, along with additional software to help in debugging, and automating the execution of Unit Tests. I use VirtualBox to actually manage the virtual machine, but other pieces of software like VMWare could be used. Since VirtualBox is freely available, I’ll focus on installing and using it.
Whenever you want to start a development session, simply ‘turn on’ the virtual machine by issuing the command
Preparing Your Host System
The actual VVV code that is used to provision our local development server is hosted on Github.
As such, it is a really good idea to have GIT installed on your system, and have the ability to clone repositories to your local machine. Make sure that you install the actual command line tool as opposed to a GUI. Verify that GIT is properly installed and working on your host system by echoing GIT’s current version number:
Two other pieces of software are needed in order for VVV to work, so install them for your system (versions are as of the time of writing):
Verify that both VirtualBox and Vagrant are installed by testing for them on the command line:
vboxmanage -v vagrant -v
Both of the above commands should echo the correct version of the software that you installed.
Nice (really nice) to Have: Install the vagrant-hostsupdater plugin, which automatically updates your host machine’s
hosts file with the appropriate dev urls for this vvv machine. Install this after installing Vagrant by executing the following in the terminal:
vagrant plugin install vagrant-hostsupdater
Nice (really nice) to Have: Install the vagrant-triggers plugin, which allows for certain actions to be hooked into various vagrant events. If this plugin is installed, VVV will execute a
db_backup script on
vagrant suspend, or
vagrant destroy. Install this after installing Vagrant by executing the following in the terminal.
vagrant plugin install vagrant-triggers
Note: The above is all you need for this quick ramp up guide. As you continue to use VVV, you will want to add additional local sites to this machine. There exists a script called vv, which automates a number of the steps in creating a new local dev site. For a closer look, see my write up on vv here in the knowledge base.
To get VVV, clone the repository to your local machine, in a place that is handy for you to access. For me that is in a folder right below my home directory:
cd ~/ git clone email@example.com:Varying-Vagrant-Vagrants/VVV.git vvv
I prefer a slightly more stable VVV, so after cloning I navigate into the repo and checkout the latest stable commit, in this case, version 1.2.0.
cd vvv git checkout 1.2.0
Turning VVV On
Anytime you want to use VVV, you need to turn it on. You do this by navigating to the place where you cloned vvv, and issuing
vagrant up. So using the above example, we would issue the following command:
cd ~/vvv vagrant up
It will take a significant amount of time for the machine to be ‘turned on’ the first time
vagrant up is issued. For me, doing this with an average download rate of around 500kb/s, I was able to be up and running in about 45 mins. This is due to a couple of things:
- Vagrant needs to download the base box it will use to provision the virtual machine. The VVV project (at the time of this writing) was using an Ubuntu 14.04 box as it’s basis, which means approximately 375mb of data needs to be downloaded.
- The base box is just a plain Ubuntu server. Once Vagrant starts provisioning, it will need to download and configure the software to make the server useful. This includes a basic LEMP server (MySQL, Nginx, PHP) as well as other tools like git, xDebug, wp-cli, and WordPress itself. For a fuller list of what is installed, see VVV’s Github page, under the what you get section.
vagrant up commands will take significantly less time since this virtual machine has been created, and provisioned. Even if you create a new, different instance of vvv (essentially create a new, local dev server), this will take less time since the base box has already been downloaded and is cached on your local machine.
Out of the Box WordPress in VVV
If you installed the the
vagrant-hostsupdater plugin, then you can access a recent, stable version of WordPress at local.wordpress.dev. For a list of other urls created by default, and the various credentials used to login and interact with this server, see the VVV repo’s section of Credentials and Such.
If you didn’t install the
vagrant-hostsupdater plugin, then you need to update your
hosts file directly, pointing the various local urls to the virtual machine:
192.168.50.4 vvv.dev local.wordpress.dev local.wordpress-trunk.dev src.wordpress-develop.dev build.wordpress-develop.dev
This should give you a great starting point for sandboxed, local WordPress development. Out of the box, we now have a snapshot of the most recent stable version of WordPress which we can use to test themes or plugins. In future Knowledge Base articles, we’ll dive deeper into using VVV for more advanced WordPress development.