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,VVV Dashboard and VV Variable (optional, but still worth it IMO).
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
Currently with VVV Dashboard there are some issues with VVV2 in that it doesn’t display sites provisioned natively.
Native Provisioning or Variable VVV
Native provisioning for additional sites is done via the vvv-custom.yml file which doesn’t exist in a VVV fresh install, what you do is copy the existing vvv-config.yml and rename it vvv-custom.yml – that way your modifications are preserved when VVV is updated.
Once the custom file is made create a new site called test.dev you could add under the sites section…
test: repo: https://github.com/Varying-Vagrant-Vagrants/custom-site-template hosts: - test.dev
This is creating a site but with a custom WordPress site repo link provided by VVV, you can add your own repo.
When you have made changes do a provision for them to take affect…
Single Site Provision in VVV2 – quick
vagrant provision --provision-with=site-<sitenamehere>
Or All Sites Provision in VVV2
vagrant reload --provision
Now you will have a working new WordPress site at test.dev
Create new sites using Variable VVV
Provisioning with Variable VVV is not quite compatible with VVV2 but there is a workaround which makes it happen. Basically you need to add in the vvv-custom.yml file the name of the site before you use Variable VVV and format should be like so under sites:
test: hosts: - test.dev
Then run Variable VVV from the command line
Follow the wizard, and when ready see the new site listed in http://vvv.dev or visit the site directly.
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.
- VVV2 add a site – https://varyingvagrantvagrants.org/docs/en-US/adding-a-new-site/
- VVV2 provisioning template – https://github.com/Varying-Vagrant-Vagrants/custom-site-template
Mentioned In Article
- 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