Using VVV Vagrant as a WordPress local development workflow is a great flexible platform, here’s mine which uses 5 bits of software to create a vagrant box.
VirtualBox,Vagrant, VVV, VV Variable and VVV Dashboard.
Each of these bits build on the other and when put together make an environment that simulate a modern web production hosting platform.
Next download and install Vagrant
I recommend installing 2 Vagrant plugins one is for host mapping, the other backs up the WordPress databases when Vagrant is halted – do this in the Terminal, just cd to your home directory and run.
vagrant plugin install vagrant-hostsupdater vagrant plugin install vagrant-triggers
Installing the VVV, VVV Variable and VVV Dashboard
Next is to install VVV which is the script that installs the 4 WordPress versions. The latest stable version, the latest trunk version and two other versions containing source and build files.
For VVV, VVV Variable and VVV Dashboard I recommend installing them with Git but you can also download the zips and move everything in place.
You can also install VVV Variable via HomeBrew which will also fix up the path issue mentioned later.
VVV (Varying Vagrant Vagrants)
git clone https://github.com/Varying-Vagrant-Vagrants/VVV.git localdev
So cloning the VVV repo above I am creating a directory to store it called localdev, if you don’t pass in a name it will create and store the files in a directory named VVV which is fine too.
git clone https://github.com/bradp/vv.git
This will add the Variable VVV files in a directory named vv
Move into your VVV installation root directory
git clone https://github.com/topdown/VVV-Dashboard.git dashboard
Move the whole dashboard directory into VVV/www/default/
And from the dashboard directory copy/move the dashboard-custom.php file to the folder above – VVV/www/default/
First Time Boot Up
So that’s all the software installed, now in Terminal, change directory to your development directory either localdev, VVV of other one you set and run…
Time for a break whilst the vagrant box is built and software installed and configured which is known as provisioning. When it is all finished you will be able to login and view the 4 default sites that VVV creates.
Default VVV Sites
When it is finished Go to http://vvv.dev and see the 4 default VVV WordPress sites – these 4 versions of WordPress are updated each time the provision script is run – you can force it by running
The WP-Admin logins to these sites and also ones created with the vv command are admin/password.
You can also access phpMyAdmin via the Built In VVV Tools and the phpMyAdmin login is root/root
Create new sites using VVV Variable
To create new WordPress sites you use VVV Variable which uses the command vv – first up is to add vv to your shell path so you can run the command from anywhere in the Terminal. If you do not know how to add it to your path – this guide should help.
If you added VVV Variable via HomeBrew then the path issue is not an issue.
So to create a new WordPress install use:
Follow the wizard, and when ready see the new site listed in http://vvv.dev or visit the site directly.
Using VVV Variable with Custom Provisioning
Every new site spun up will use the same provisioning as the initial vagrant up command, this is overkill and can take between 6-10mins, you can use a custom provision script by adding a file to the provision directory which sits in the root level of your development folder.
If this file exists it will take priority when provisioning occurs. The trick here is to edit the original provision.sh script and remove all the stuff not required for straight site set ups. But do remember that to keep the whole VVV files up to date do actually run the full provisioning script from time to time.
Here is a link to my custom script. This can spin up WordPress sites for me in around 60 seconds.
Since I initially wrote this post Brad Parbs has released a custom provisioning script called VVV Provision Flipper, this is great tool for quick provisioning.
Using BluePrints with VVV Variable
You can set up blueprints with vv by running:
This will create a sample json file in the root directory of your development called vv-blueprints.json, use this as a starter and append multiple ones in the same file, give each a unique name and follow the json formatting. Use call the blueprint when going through the vv create wizard.
Halting and Destroying the Vagrant Box
To halt the vagrant box run
To run it up again run
To delete the box run
To ssh into the box
By running vagrant destroy your WordPress files are still intact in your development/www folder and if you have the vagrant triggers plugin installed the databases are backed up in database/backups.
- VirtualBox – https://www.virtualbox.org
- Vagrant – https://www.vagrantup.com
- VVV Vagrant – https://github.com/varying-vagrant-vagrants/vvv/
- Variable VVV – https://github.com/bradp/vv
- VVV Dashboard -VVV Dashboard – https://github.com/topdown/VVV-Dashboard
- provision-custom.sh – https://gist.github.com/neilgee/021b02c11546d8847e2d
- VVV Provision Flipper – https://github.com/bradp/VVV-Provision-Flipper
- Vagrant Manager – http://vagrantmanager.com/
- VVV Dashboard https://github.com/leogopal/VVV-Dashboard
- VVV SiteWizard – https://github.com/aliso/vvv-site-wizard
- VVV Apache – https://github.com/ericmann/vvv-apache