Developing with WordPress – part 5: Multisite on VVV

WordPress supports the use of multisite, a functionality that lets you set up multiple WordPress installations with the same codebase. You can use multisite as a solution when you need to create multiple sites with largely the same functionality but still need to look and feel a bit different from each other. For example, a real estate agency could use multisite to have different sites for every property they are offering: the functionality will mostly, if not completely, be the same on each site, but the used layout and media is different.

As it would be tedious to do WordPress and plugin updates on each site separately you can use multisite for that: sharing the same codebase and making updates that happen everywhere at once. But how do you set this up in VVV?

Multisite in VVV

Setting up a multisite installation in VVV isn’t that much different than setting up a single site. There are however a few small changes in the config files you need to do and those can give you quite a headache if you don’t know what you should do.

I will show you how to set up a multisite that is running on http://multisite.test and has a subsite that runs on http://subsite.multisite.test .

We start with adding our site to vvv-custom.yml :

 - multisite.test
 - subsite.multisite.test

So compared to setting up a single site, multisite requires you to add multiple hosts.

Now we create the multisite directory in vvv/www and create there the provision folder with the and vvv-nginx.conf files. Follow the instructions from part 2 of this series if you have forgotten how to do that. Do not provision VVV yet.

We have to modify the vvv-nginx.conf file in the provision folder first. Open this file and replace this line:

server_name 6604.local;


server_name multisite.test subsite.multisite.test;

This tells Nginx to use both domains. Now here is the tricky part, as you notice I have used the 6604 variable in the original vvv-nginx.conf file, but have replaced that with the actual name of the site in the one for multisite setup. This is because Nginx will give an error if you use this variable twice in the same line!

Once you have made this change you can go ahead and start provisioning VVV. The VVV config changes are done, now set up WordPress accordingly.

Multisite setup in WordPress

First just install WordPress as you usually do. Open http://multisite.test in your browser and follow the instructions.

WordPress requires a few changes in its config as well, so let’s continue with that. Open your wp-config.php and add the following line:

define( 'WP_ALLOW_MULTISITE', true );

Now when you refresh the WordPress admin you will find a new menu item ‘ Network Setup’ under Tools. Click that and follow the instructions. Choose for subdomains and continue the process. WordPress eventually will give you instructions on some lines you need to add to wp-config.php. Add those lines. WordPress might also give you instructions for your .htaccess file, but as we are using Nginx you can just ignore this.

WordPress is now set up to start accepting multisites. Refresh your browser again and in wp-admin go to My Sites > Network Admin > Sites. Add a new site with the URL subsite.multisite.test and you are done. Open http://subsite.multisite.test in your browser and you will see that it runs as expected.

Adding more sites to your multisite

When you want to add more sites to your multisite setup you will have to add the corresponding URL to vvv-custom.yml and vvv-nginx.conf and then provision VVV again. After that you can add the site in WP admin as described above.


Modifying the vvv-custom.yml and vvv-nginx.conf files and then provisioning VVV is a small task but it does take time, especially the provisioning can easily take up 5 to 10 minutes if you have a lot that needs to be done. So wouldn’t it be easier to use wildcards instead? Adding *.multisite.test to your vvv-custom.yml and vvv-nginx.conf files? The answer is yes, that would be easier. But unfortunately wildcards are currently not yet supported by VVV. So for now we just have to add every site manually.

Multisite usage

The instructions above have shown how to set up multisite in VVV. It doesn’t tell you much yet on how to use it and for that I would refer to the official documentation. You can use that as a good starting point to explore the possibilities of this nice feature.

Share on social media:

Latest blogs