Published:

How to add a new WordPress instance in VVV?

If you're about to start a new project based on WordPress and decided to go with VVV as your local runtime environment, here is a short list of instructions on how to setup a new WordPress instance within VVV.

Disclaimer: These are only quick and dirty notes. A more canonical tutorial can be found here. There are even more automatic solutions to the problem.

Either way, you might find the following useful.

Adding a new site to VVV

  1. Create a new directory within {vvv-home}/www/, e.g. {vvv.home}/www/example.org.
  2. Create a new Nginx config file within {vvv-home}/config/nginx-config/sites/. You may already have added a custom WP instance before. Copy it, give it a meaningful name like example.dev.conf and edit it accordingly. Within the file I usually change the TLD from the real one to .dev. Reason? To not mess up with global DNS once the site is live because in the next step we're adding the domain to our local hosts file.
  3. Adapt your hosts file. For Windows it's in System32/drivers/etc/hosts. Make sure you edit the file with administrator priviledges.
  4. Go on with provisioning the database. Edit the {vvv-home}/database/init-custom.sql file. If you would like to create a new database user, I recommend creating it manually beforehand, since the shipped MySQL server might not support CREATE USER IF NOT EXISTS.
  5. Call vagrant up and then vagrant provision. provision takes care to execute the configuration changes you just did. Hint: this can take several minutes to complete.
  6. Test if the newly created website is available under the configured domain name (see the newly created Nginx config file). E.g. http://example.dev if you decided to run the website with the .dev TLD locally.
  7. If you don't have it on your disk already, download the WordPress distribution and extract it to the previously created home directory of the website, i.e. {vvv-home}/www/example.dev/. Here's a neat command to extract the files: tar -xf wordpress-4.6.1.tar.gz -C /d/foo/bar/vvv/www/example.dev/
  8. Granted that the virtual machine is up through vagrant up, browse to the domain that you've registered in your hosts file.
  9. Use the WordPress installation wizard to setup your site. You're done.

Published by Robert Möstl

« Back to Blog