This is a 4 part reference guide to getting started with Vagrant, VVV and WordPress.
This is Part 2 – Setting up VVV Varying Vagrant Vagrants on macOS
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 that you get in your VVV Box
- nginx (mainline version)
- MariaDB 10.1.x (drop-in replacement for MySQL)
- php-fpm 7.0.x
- WP-CLI (master branch)
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 or 3 plugins are optional, which they are, but to have VVV up and running without further configuration 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.
Navigate 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 for example it will back up your databases when vagrant is halted or shut down.
VirtualBox Guest Plugin
vagrant plugin install vagrant-vbguest
If you get errors installing the plugins, most of these related to network timeouts, just repeat the process. Don’t worry about the location of where you filing at this point as these are global plugins.
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-develop.zip to your downloads directory, unzip it and rename it to ‘VVV’. You can leave it in Downloads or move it to another location. The ‘develop’ branch is actually the latest VVV2 version, the ‘master’ branch is the previous version.
I would recommend making the install in a folder in your home directory – to get to your home directory just run cd on the command line.
I currently use the develop branch as it has the latest fixes and is very active – if you prefer you can also use the master branch.
To clone the github repo VVV on your local machine – for the develop branch us:
git clone -b develop git://github.com/Varying-Vagrant-Vagrants/VVV.git
git clone -b master git://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 -b develop git://github.com/Varying-Vagrant-Vagrants/VVV.git vagrant-local
git clone -b master git://github.com/Varying-Vagrant-Vagrants/VVV.git vagrant-local
Booting up VVV
In this example the VVV directory is filed in the home folder – in Terminal change directory into the folder
Start VVV by issuing the above ‘vagrant up’ command. Output should be similar to and ongoing:
neilg@[~/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 and cached.
Now everything is installed, in your browser go to http://vvv.dev/ to see your sites.
The below sites are installed by default and are located in your browser as:
- http://local.wordpress.dev/ for WordPress stable
- 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
As well as some links to some web dev tools on your Vagrant VM Box including phpmyadmin, phpinfo and mailcatcher.
Usernames and Passwords
To access the back-end of WP & MySQL the logins are below:
WordPress WP-Admin login username/password instances are
MySQL db and dbUser/password is
MySQL root user/password 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.
Logging In To the VM Box
To access the virtual box (optional), you do so via SSH and the mirror directory to your current working vagrant directory after login is in the root at /vagrant
Run a ls command to see that content
vagrant@vvv:~$ cd /vagrant vagrant@vvv:/vagrant$ ls -la total 56 drwxr-xr-x 1 vagrant vagrant 442 Jul 17 04:40 . drwxr-xr-x 1 vagrant vagrant 680 Mar 2 2017 . drwxr-xr-x 23 root root 4096 Mar 2 07:41 .. -rw-r--r-- 1 vagrant vagrant 15785 Mar 2 07:28 CHANGELOG.md drwxr-xr-x 1 vagrant vagrant 578 Mar 2 07:48 config drwxr-xr-x 1 vagrant vagrant 238 Mar 2 07:28 database drwxr-xr-x 1 vagrant vagrant 102 Mar 2 07:28 docs -rw-r--r-- 1 vagrant vagrant 6148 Mar 2 2017 .DS_Store drwxr-xr-x 1 vagrant vagrant 408 Mar 2 07:28 .git -rw-r--r-- 1 vagrant vagrant 69 Mar 2 07:28 .gitattributes drwxr-xr-x 1 vagrant vagrant 136 Mar 2 07:28 .github -rw-r--r-- 1 vagrant vagrant 1849 Mar 2 07:28 .gitignore -rw-r--r-- 1 vagrant vagrant 1107 Mar 2 07:28 LICENSE drwxr-xr-x 1 vagrant vagrant 102 Mar 2 07:28 log drwxr-xr-x 1 vagrant vagrant 238 Mar 2 08:06 provision -rw-r--r-- 1 vagrant vagrant 6973 Mar 2 07:28 README.md drwxr-xr-x 1 vagrant vagrant 102 Mar 2 07:36 .vagrant -rw-r--r-- 1 vagrant vagrant 17815 Mar 2 07:28 Vagrantfile -rw-r--r-- 1 vagrant vagrant 675 Mar 2 07:28 vvv-config.yml -rw-r--r-- 1 vagrant vagrant 64 Mar 2 07:28 wp-cli.yml drwxr-xr-x 1 vagrant vagrant 238 Mar 2 2017 www
Your sites are in www directory, which is the same on your host – ~/VVV/www
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.