How to set up a wordpress multisite with subdomains on a local server on windows with wamp

by

WordPress Multisite is a method to publish many site on a specific domain. Each Site has it’s own design and its onw dashboard to manag it, but it also has a master configuration.

let’s say we have a website domain called “site-domain.net”. you can configure it in two ways:

  • as subdomains: sub1.site-domain.net, sub2.sitedomain.net …
  • as subfolders: site-domain.net/sub1, site-domain.net/sub2 …

When you want to have a copy of your website locally, to work on it maybe also offline, you need to have a local webserver with functionalities that support wordpress.

When you work with a local webserver, the default localsite servername is “localhost”. But der are some restrictions to wordpress multisites when working locally. in “Before You Create A Network“, you find the following restrictions:

You cannot choose Sub-domain Install (for a domain-based network) in the following cases:

    • The WordPress URL contains a path, not just a domain. (That is, WordPress is not installed in a document root, or you are not using the URL of that document root.)
    • “WordPress address (URL)” is localhost
    • “WordPress address (URL)” is IP address such as 127.0.0.1.

(Note that you can create a domain-based network on your local machine for testing purposes by using your hosts file to map some other hostnames to the IP address 127.0.0.1, so that you never have to use the hostname localhost.)

In the following, we look how to setup a local webserver on windows with WAMP-server.


Configuring WAMP Server locally – Working with Virtual Hosts

The method to work with sumdomains on a localhost is setting up and configuring virtual hosts.
Technically is needs the configuration of two files:

  • httpd-vhosts.conf of WAMP Server
  • hosts on windows.

httpd-vhosts.conf

Here you define the name of the virtual hosts and the path where the webcontent, e.g. the wordpress installation path, is. There are more settings included.
Depending on how to set it up, you make a virtual host for each domain and subdomain individually, or when working with alias, you can use wildcards.
the default location of httpd-vhosts.conf is, depending of the server version C:\wamp64\bin\apache\apache2.4.41\conf\extra.

hosts

In this file you allow windows to find the virtual host by the system. Eack local domain as well as their subdomains require an individual entry.
The hosts file is found at C:\Windows\System32\drivers\etc


A sample configuration on Wamp Server on Windows for local (offline) usage

Localsite: sitedomain.local
Subdomains: sub1, sub2
Path of local installation: D:/www/wp_sitedomain

httpd-vhosts.conf

This setup-sample uses the wildcard * for subdomains of sitedomains.local in ServerAlias.

hosts


How to set up

When you Use the “Virtual Hosts Manager” of Wamp server, it includes the setup in both httpd-vhosts.conf and hosts.

  • With Virtual Hosts Manager, the subdomain wildcard * in ServerAlias can not be set there, you have to edit httpd-vhosts.conf manually, and you even hav to set an entry for each subdomain in “hosts” manually.
  • If you don’t want to configure vhosts.conf and hosts manually, you define each domain and subdomain in Virtual Hosts Manager. This will also configure hosts-file with the subdmains. For wordpress multisites with subdomains, the path of installation is the same for site and sub-sites.

Good Luck!


last update: 31.03.2020
published: 27.03.2020

Print Friendly, PDF & Email

Add a Comment

Your email address will not be published. Required fields are marked *