This is a 4 part reference guide to getting started with Vagrant, VVV and WordPress.
This is Part 3 – Adding Multiple Sites Natively and with Variable VVV
Vagrant and WordPress Local Development – Spinning up WordPress sites natively and using VVV Base
Once you have Vagrant and VVV Varying Vagrant Vagrants up and running by default there are these following WordPress installs and corresponding webroot directories:
- local.wordpress.test
- src.wordpress-develop.test
- build.wordpress-develop.test
As well as these default sites, you can use a script to power up any number of additional WordPress sites either provisioning them natively and using Variable VVV – The Best VVV Site.
Provisioning additional WordPress sites natively
In your VVV install is a configuration file called vvv-config.yml this is the file that has the config for the 3 default sites loaded with VVV as outlined above.
To make additional sites copy the file and rename it vvv-custom.yml, that way when you update your version of VVV you won’t lose your new settings for additional sites as the original vvv-config.yml file will be overwritten.
--- sites: # The wordpress-default configuration provides a default installation of the # latest version of WordPress. wordpress-default: repo: https://github.com/Varying-Vagrant-Vagrants/vvv-wordpress-default.git hosts: - local.wordpress.test
Looking at one of the default sites will indicate how to format the new additional sites which have to be added under the sites: section, give the site a name to identify, a repo to pull the WordPress install and a host url. Follow the .yml space indentation to avoid syntax errors.
So for example to create a new site called testsite.test you could add under the sites section…
test: repo: https://github.com/Varying-Vagrant-Vagrants/custom-site-template hosts: - testsite.test
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-test
Or All Sites Provision in VVV2
vagrant reload --provision
Now you will have a working new WordPress site at testsite.test
vagrant reload --provision
Now you will have a working new WordPress site at testsite.test
VVV Base
Create new custom WordPress sites using VVV Base
VVV Base is a custom provisioning script which does a fantastic job of customising a new WordPress site including adding themes and plugins or a whole wp-content folder, you can also set db prefix, locale instance and more.
It is also set up in the vvv-custom.yml file with a format similar to…
testsite: repo: https://github.com/JPry/vvv-base hosts: - testsite.test custom: admin_user: admin admin_password: password admin_email: [email protected] title: Just another VVV web site db_prefix: wp_ multisite: false xipio: true version: latest locale: en_AU themes: - { theme: "/vagrant/zips/bb-theme.zip", force: false, activate: false } - { theme: "https://github.com/neilgee/beavertron/archive/master.zip", force: false, activate: true } - { theme: "/vagrant/zips/lib.zip", force: false, activate: false } delete_default_plugins: true delete_default_themes: true wp: true
Then you provision it…
vagrant provision --provision-with=site-testsite
See the VVV Base site for more info on the options available for provisioning.