How to Set up WordPress Multisite with Apache Web Server on Ubuntu

This tutorial is going to show you how to set up WordPress Multisite with Apache Web server. It’s assumed that you have already installed WordPress with LAMP stack on a Ubuntu server. If not, please check out the following tutorials.

Ubuntu 16.04

Ubuntu 17.10

What is WordPress Multisite

It’s a feature that enables you to host multiple websites on a single WordPress installation. The best example is, which hosts tens of millions of websites on a single WordPress installation.

There are two types of WordPress multisite

  • sub-domain multisite, which is the most common type and used by blogs
  • sub-directory multisite

In this tutorial, I will show you how to set up sub-domain type of multisite and how to set up domain mapping, so that you can map a new domain name to a sub-domain. As a matter of fact, uses domain mapping so that customers can choose their own domain names ( instead of sub-domain (

Steps to Set up WordPress Multisite

1. Edit wp-config.php File

Cd into your WordPress installation directory like below:

cd /var/www/

Edit wp-config.php file with your preferred text editor.

sudo nano wp-config.php

Find this line: /* That’s all, stop editing! Happy blogging. */ (usually at the end of the file). Then add the following line to enable the Network feature.

define('WP_ALLOW_MULTISITE', true);

wordpress multisite apache

Save and close the file. Next, go to your WordPress Dashboard in your Web browser. You now see a new item, labeled Network Setup, under the Tools menu. Click the Network Setup link in the Tools menu. If you have any plugins activated, please deactivate them for a moment.

wordpress multisite sub-domain

2. Enable Apache mod_rewrite module

The Network Setup page will tell you to enable the Apache mod_rewrite module. You can check if it is enabled by running the command below.

sudo apache2ctl -M | grep rewrite

If it’s already enabled, you will see this line:

rewrite_module (shared)

Otherwise enable it with:

sudo a2enmod rewrite

3. Enable .htaccess File

We also need to enable .htaccess file because later we will need to add some directives in this file to enable WordPress multisite. To enable .htaccess file, edit the Apache vhost configuration file for your WordPress site like below.

sudo nano /etc/apache2/sites-available/

Add the following lines inside <VirtualHost> tag. Replace /var/www/ with your own document root directory.

<Directory "/var/www/">
         AllowOverride All

Save and close the file. Just so you know, .htaccess file is also needed for WordPress permalink to work. Now restart Apache for the change to take effect.

sudo systemctl restart apache2

4. Enable the Network

Then at the WordPress Dashboard, choose sub-domains and click Install button.

wordpress multisite ubuntu

To use a subdomain configuration, you must have a wildcard entry in your DNS. To create a wildcard DNS record, enter * in the name field and enter your server IP address in the value field in your DNS manager.  The following is an example of a wildcard entry in CloudFlare DNS manager.

wordpress multisite wildcard DNS record

Then next page will tell you to add some configurations in wp-config.php file and the .htaccess file. Note that you need to delete existing rewrite rules in .htaccess file and then add the new rewrite rules.

wordpress multisite domain mapping

Once that done, click the log in link at the bottom of the page to re-login.

Create a New Site in the Network

With the WordPress Network now fully enabled and configured, you see a new link in the menu at the top right of your WordPress Dashboard called My Sites. To create a new site, go to My Sites -> Network Admin -> Sites.

WordPress multisite htaccess

Click Add New button and enter site URL, site title, admin email.

wordpress multisite add a new site

You can add many sites as you want.

Install Themes and Plugins

Individual site admin can’t install new themes and plugins. Only the network admin can do that. Go to My Sites -> Network Admin -> Dashboard. From there, the network admin can install themes and plugins and apply changes that affect the whole network. Once a theme or plugin is network-enabled, individual admins can enable it from their dashboard.

How to Set up Domain Mapping

If you want to add a top-level domain in the WordPress multisite network, you need first to create a subsite in the network, like, then use domain mapping to map the top-level domain like to

Here are the steps.

First, create DNS A record for the top-level domain you want to map. It should point to the IP address of your WordPress site.

Then, create a subsite in the WordPress multisite network.

Next, go to My Sites -> Network Admin -> Sites, click edit button of the newly-created subsite. In the Site Address field, replace the URL with the top-level domain you want to map.

wordpress multisite domain mapping ssl

Save your changes and you are done. Now when a visitor enter in web browser, it will be redirected to under the hood without being noticed by the visitor.

I hope this tutorial helped you set up WordPress multidomain and domain mapping. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks.

Rate this tutorial
[Total: 2 Average: 5]

4 Responses to “How to Set up WordPress Multisite with Apache Web Server on Ubuntu

  • Ivy Rings
    4 years ago


    I like your tutorials ! I was wondering how to add free SSL certificate for free (e.g. through lets encrypt certbot) for all the sites in the multi-site network, hopefully in one shot(one certificate for all sites)? I am only interested in running on my self-hosted server (i.e setup my own server on digital ocean), not managed solutions. If you could write a tutorial on this, that would be fantastic. Of course, email me instruction would work too. Thanks a lot !

  • Thanks man! it works for me for version 5.5.1 and ssl setup

  • Armandt Burger
    4 years ago

    Hi Xiao,
    I have multiple websites on my server, and now i have a requirement for a site to utilize multisite.

    When a create a sub-domain site on the multisite and i visit the page i only see the Apache2 Ubuntu Default Page.
    Can you maybe advise on where i went wrong ?

    When i try to reach the dashboard, i get redirected to a website on the server that should not be connected to the multisite website

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community ( for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here