Vagrant is a very powerful development tool that allows you to use virtual images referred to as boxes to use as your local development environment. You can download and use a number of virtual ‘boxes’ with the aid of a virtual machine application like the free VirtualBox, you can also create and share your own boxes with colleagues via the Vagrant Cloud.
Some good folks have got together and released a virtual box image suitable for local WordPress development called VVV aka Varying Vagrant Vagrants.
Install Virtual Box and Vagrant
Installing VVV Varying Vagrant Vagrants
Key components you get in your VVV Box
- Ubuntu 14.04 LTS
- WordPress Develop
- WordPress Stable
- WordPress Trunk
- nginx 1.6.x
- mysql 5.5.x
- php-fpm 5.5.x
- memcached 1.4.13
- PHP xdebug extension
You get all the above and some more which cover the full gamut of WordPress theme and plugin development. Before you install the main VVV it’s best to install 2 needed plugins.
Install Vagrant Plugins
The GitHub instructions for VVV say these steps for 2 plugins are optional, which they are, but to have VVV up and running without further AMP config it’s best to install these plugins prior to running vagrant up otherwise you will need to do further configuration to get Nginx, PHP and MySQL running. It doesn’t particular matter where you are at this point just be in hour home directory.
vagrant plugin install vagrant-hostsupdater
Install this plugin which will add the required host mapping on your /etc/hosts file for the default local development URLs
vagrant plugin install vagrant-triggers
This plugin allows specific VVV scripts to fire on boot and on halt of the virtual image.
If you get errors installing the plugins, most of these related to network timeouts, just repeat the process.
Install VVV – Varying Vagrant Vagrants
If you are comfortable with Git you can clone the repo locally, otherwise download the zip archive from GitHub VVV-master.zip to your downloads directory, unzip it and rename it to ‘VVV’. You can leave it in Downloads or move it to another location. To Git clone VVV:
git clone https://github.com/Varying-Vagrant-Vagrants/VVV.git
Your cloned directory will be named VVV or name it something else… in the case below, it’s named vagrant-local
git clone https://github.com/Varying-Vagrant-Vagrants/VVV.git vagrant-local
Booting up VVV
In this example the VVV directory is left in the Downloads folder – launch Terminal and move into the folder
Output should be similar to and ongoing:
neilg@[~/Downloads/VVV]: vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Box 'ubuntu/trusty64' could not be found. Attempting to find and install... default: Box Provider: virtualbox default: Box Version: >= 0 ==> default: Loading metadata for box 'ubuntu/trusty64' default: URL: https://vagrantcloud.com/ubuntu/trusty64 ==> default: Adding box 'ubuntu/trusty64' (v14.04) for provider: virtualbox default: Downloading: https://vagrantcloud.com/ubuntu/trusty64/version/1/provider/virtualbox.box default: Progress: 76% (Rate: 1462k/s, Estimated time remaining: 0:01:25)
This is the all powerful Vagrant command, the first time you run it, it will go to the Vagrant cloud and download the needed resources to boot the new VVV virtual machine in a standalone full development environment, this will take some time depending on your internet connection, maybe time for a brew, subsequent boots in the same directory will be much quicker as the core files will have already been downloaded.
To access the virtual box, you do so via SSH and the mirror directory to your current vagrant directory after login is in the root at /vagrant
Run a ls command to see that content
[email protected]:~$ cd /vagrant [email protected]:/vagrant$ ls -la total 56 drwxr-xr-x 1 vagrant vagrant 442 Jul 17 04:40 . drwxr-xr-x 23 root root 4096 Jul 17 07:24 .. -rwxr-xr-x 1 vagrant vagrant 8468 Jun 23 22:11 CHANGELOG.md drwxr-xr-x 1 vagrant vagrant 510 Jun 23 22:11 config -rwxr-xr-x 1 vagrant vagrant 1663 Jun 23 22:11 CONTRIBUTING.md drwxr-xr-x 1 vagrant vagrant 238 Jun 23 22:11 database -rwxr-xr-x 1 vagrant vagrant 98 Jun 23 22:11 .gitattributes -rwxr-xr-x 1 vagrant vagrant 1321 Jun 23 22:11 .gitignore drwxr-xr-x 1 vagrant vagrant 102 Jun 23 22:11 provision -rwxr-xr-x 1 vagrant vagrant 16239 Jun 23 22:11 README.md drwxr-xr-x 1 vagrant vagrant 102 Jul 17 04:40 .vagrant -rwxr-xr-x 1 vagrant vagrant 9269 Jun 23 22:11 Vagrantfile drwxr-xr-x 1 vagrant vagrant 204 Jul 17 04:59 www
And in the www directory there are some dev WordPress sites pre-installed you see the default available sites as below:
[email protected]:/vagrant/www$ ls -la total 4 drwxr-xr-x 1 vagrant vagrant 340 Jul 17 09:15 . drwxr-xr-x 1 vagrant vagrant 408 Jul 17 08:58 .. drwxr-xr-x 1 vagrant vagrant 272 Jul 17 09:23 default -rw-r--r-- 1 vagrant vagrant 0 Jun 24 15:11 .gitshow drwxr-xr-x 1 vagrant vagrant 544 Jul 17 09:14 phpcs -rw-r--r-- 1 vagrant vagrant 562 Jun 24 15:11 vvv-hosts drwxr-xr-x 1 vagrant vagrant 748 Jul 17 09:14 wordpress-default drwxr-xr-x 1 vagrant vagrant 646 Jul 17 09:22 wordpress-develop drwxr-xr-x 1 vagrant vagrant 782 Jul 17 09:15 wordpress-trunk drwxr-xr-x 1 vagrant vagrant 714 Jul 17 09:12 wp-cli
The below sites are installed by default and are located in your browser as:
- http://local.wordpress.dev/ for WordPress stable
- http://local.wordpress-trunk.dev/ for WordPress trunk
- http://src.wordpress-develop.dev/ for trunk WordPress development files
- http://build.wordpress-develop.dev/ for the version of those development files built with Grunt
- http://vvv.dev/ for a default dashboard containing several useful tools
So for example http://local.wordpress.dev/ the webroot is /vagrant/www/wordpress-default, this WordPress install has the latest WordPress stable release.
The http://local.wordpress-trunk.dev has the latest beta release so here it would be WordPress 4.0.X or similar, the instance of wordpress-develop is set up for contribution to WordPress core.
Usernames and Passwords
To access the back-end of WP & MySQL the logins are below:
WordPress WP-Admin instances are
MySQL db and dbUser is
MySQL root user is
That’s it, the Vagrant VVV instance can be shutdown with vagrant halt and booted with vagrant up – to totally remove it you can run vagrant destroy.
I have a similar all in one article on WP Beaches website to get VVV and WordPress up to speed on a local Vagrant/WordPress workflow.