One place for hosting & domains


      How To Set Up WordPress Multisite with Nginx and LEMP on Ubuntu 20.04


      The WordPress multisite feature is a unique way to host and manage a suite of sites in one place, and is useful for projects or positions that call for the operation of several WordPress sites under one host. Multisite offers the ability to create multiple WordPress websites from a single installation of WordPress, with each site having a separate theme, set of plugins, and collection of content (typically posts and pages). This feature helps to reduce the overhead of maintaining and updating several installations of WordPress, while allowing you to host multiple sites which may be unrelated to one another.

      In this tutorial, you’ll set up a WordPress multisite on an Ubuntu 20.04 Droplet using subdomains. The WordPress sites that you’ll create will have a subdomain web address like, but your subdomain address can be mapped to an external domain like so that each site looks independent to users visiting your multisite suite of addresses.


      This tutorial requires you to have a basic knowledge of WordPress multisite. The following articles might be helpful in deepening your understanding of multisites:

      Step 1 — Installing WordPress

      For this tutorial, you’ll need to have access to a WordPress Droplet running the LEMP stack on Ubuntu 20.04. You can create a WordPress installation on a Droplet in the following ways:

      You can also follow this tutorial using a WordPress installation on a hosting provider, but keep in mind that the steps of this tutorial will reflect a WordPress multisite setup on a DigitalOcean Droplet.

      Before installing WordPress, you’ll need to set up DNS records for each intended WordPress site in your multisite installation. For this tutorial, create the following domain names:

      • Site 1:

        Domain: (Primary domain)

        This is the site that is created when WordPress is installed.

      • Site 2:

        External Domain:


      • Site 3:

        External Domain:


      The first domain is the primary domain name through which WordPress will be referenced. Make sure to set up DNS for all three domains to point to the IP address of the Droplet hosting WordPress.

      While installing, if you’ve chosen to use a Droplet with a LEMP stack, be sure to follow the instructions for setting up your database and users. For DigitalOcean WordPress 1-Click installations, this has already been configured for you.

      After installing WordPress on your Droplet, let’s assign file ownership to the user www-data. This is essential for media uploads and for core/plugin/theme updates to work in WordPress.

      Log in to your Droplet via the command line, then execute the following command, replacing the highlighted path with the full path to your WordPress installation:

      • chown -R www-data:www-data /var/www/wordpress/

      This command will grant read and write access to the www-data user for media uploads and necessary updates.

      In the next step, we’ll further configure the primary domain, then configure our multisite installation from there.

      Step 2 — Setting Up DNS Wildcard Records

      Let’s continue by adding a DNS wildcard record for the primary domain. Adding a wildcard record allows more WordPress sites to be added to your multisite installation at any time, without needing individual A records. Alternatively, you can choose to add a new A record for each subdomain.

      Log in to your DigitalOcean control panel and navigate to the Networking section. Edit the primary domain and create a wildcard A record for this domain pointing to the Droplet’s IP address. A wildcard record is created by entering an asterisk (*) in the hostname input box as shown in the following screenshot.

      DNS Control Panel - wildcard record

      If you host your domain’s DNS on a hosting provider, set the wildcard record using the registrar’s site.

      After setting the wildcard record, DNS queries for any should return the IP address of your Droplet.

      Step 3 — Enable Multisite and Create Additional Sites

      In this section, let’s now enable our WordPress multisite and create the two additional sites as mentioned in Step 1.

      To begin this process, a PHP constant has to be defined in the wp-config.php file to enable the Network Setup page.

      You can edit the wp-config.php file via the command line while logged into your WordPress Droplet. Open the file using your command line editor of choice. Here, we’ll use nano:

      • nano /var/www/wordpress/wp-config.php

      Add the following code before the comment /* That's all, stop editing! Happy blogging. */ or similar text:


          /* Multisite settings */
          define( 'WP_ALLOW_MULTISITE', true );

      Save and close the file. If you’re using nano, you can do that with CTRL+X, then Y and ENTER to confirm.

      Next, log in to the WordPress admin panel and navigate to Tools -> Network Setup. Choose the Subdomains option, modify the Network Title as desired, and then click Install.

      WordPress Network Setup

      You will be presented with two blocks of code to be added in the wp-config.php and .htaccess files. Because we are using Nginx, we won’t need to use the suggested .htaccess code, so you can ignore that for now.

      Copy the wp-config.php code which looks similar to the following:

          define('MULTISITE', true);
          define('SUBDOMAIN_INSTALL', true);
          define('DOMAIN_CURRENT_SITE', '');
          define('PATH_CURRENT_SITE', '/');
          define('SITE_ID_CURRENT_SITE', 1);
          define('BLOG_ID_CURRENT_SITE', 1);

      Next, open the wp-config.php file:

      • nano /var/www/wordpress/wp-config.php

      Include the code snippet you just copied, placing it before the comment that says /* That's all, stop editing! Happy blogging. */ (or a variation of text that advises not to write below it). Save the file when you’re done.

      Log out of the WordPress admin panel, and log in again. From the admin toolbar on the top left, navigate to the My Sites > Network Admin > Sites.

      WordPress Toolbar

      Click the Add New button to open the Add New Site form. The following screenshot shows the filled-in details for the shopping site in our example. The Site Address entered will form the subdomain of this site.

      Creating a new WordPress site

      Click Add Site and the created site will be accessible via

      Repeat these steps to create the second site ( in our example).

      The following three WordPress sites can now have its own content, theme, and active set of plugins:


      Step 4 — Setting Up Domain Mapping

      In this step, let’s enable multisite to use a separate domain name for each WordPress site by downloading and enabling the WordPress MU Domain Mapping plugin. This third-party plugin allows users of WordPress multisite to map their blog/site to another domain.

      To download this plugin,visit My Sites -> Network Admin -> Plugins from your dashboard and select Add New on your primary domain to find the WordPress MU Domain Mapping plugin.


      Install the plugin, then click the Network Activate link under the WordPress MU Domain Mapping plugin. Go to Settings -> Domain Mapping and make changes to the Domain Options as follows:

      • Uncheck Remote Login
      • Check Permanent Redirect
      • Uncheck Redirect administration pages to site’s original domain

      Domain mapping options

      Click Save once done. These settings redirect all requests for subdomains (like to their respective external domains (like including the administration pages (/wp-admin).

      In the next step, let’s map a domain name to each site based on its site ID. There are many ways to find the ID of a site, but for easier administration you’ll create a simple WordPress Must-use plugin that displays an additional ID column on the Sites page.

      Log in to your WordPress Droplet via SSH and create an mu-plugins directory.

      • mkdir /var/www/wordpress/wp-content/mu-plugins

      Create a PHP file inside this directory:

      nano /var/www/wordpress/wp-content/mu-plugins/wpms_blogid.php

      Next, copy the following content to your wpms_blogid.php file:


          add_filter( 'wpmu_blogs_columns', 'do_get_id' );
          add_action( 'manage_sites_custom_column', 'do_add_columns', 10, 2 );
          add_action( 'manage_blogs_custom_column', 'do_add_columns', 10, 2 );
          function do_add_columns( $column_name, $blog_id ) {
              if ( 'blog_id' === $column_name )
                  echo $blog_id;
              return $column_name;
          function do_get_id( $columns ) {
              $columns['blog_id'] = 'ID';
              return $columns;

      The Sites -> All Sites section should now show an additional ID column.


      Note down the ID values for each site and go to the Settings -> Domains page. Enter the site ID followed by the external domain for the site. For example, since companysite has an ID of 3, on this page, the Site ID should be 3, and the domain should be

      Mapping a site ID to a domain

      You may add a “www” prefix if you wish to set the site URL as Repeat these steps for the other domains. Click Save at the bottom of the page.

      Each site will now have its own domain name instead of a subdomain; i.e., entering in your browser will open the My Online Company site. You can check this now by visiting your additional domain names that are mapped. You should see the site title change in the upper left corner of the page.

      Now each site can be maintained separately through its own WordPress admin panel:

      - ``
      - ``
      - ``

      Updates to the core/plugins/themes and installation of plugins/themes should be done from the network admin page of the primary domain:

      - ``


      In this tutorial, you learned how to set up the multisite feature on a WordPress website running on Ubuntu 20.04 with Nginx (LEMP stack). The multisite feature enables you to host multiple WordPress sites on one WordPress installation on your droplet. You also learned how to set up domain mapping, which allows each of your subsites to be reached through a custom domain name.

      For an alternate process to install the WordPress multisite feature, visit our tutorial, Setting up WordPress Multisite on Apache.

      Source link

      How To Set Up Multiple WordPress Sites Using Multisite [Quickstart]


      WordPress is a robust content management platform, powering over 36% of the web currently. With the multisite feature, WordPress administrators can create multiple sites on one server, using a single WordPress installation, right within their dashboard.

      In this quickstart, learn how to set up multiple instances of WordPress sites that exist on one server or WordPress Droplet using the multisite feature. If you’d prefer a more in-depth walkthrough of a WordPress multisite set up, see How To Set Up WordPress Multisite with Nginx and LEMP on Ubuntu 20.04.


      The steps in this tutorial require the user to have sudo privileges. Follow our Initial Server Setup with Ubuntu 20.04 to create an administrative system user with sudo privileges.

      Before working with WordPress, you’ll need to have it installed on your virtual private server. This quickstart uses a Ubuntu 20.04 Droplet with the LAMP stack installed, with a user having root privileges. You can follow this tutorial with other installations, but keep in mind that the steps may vary depending on your installation.

      If you’ve chosen to install WordPress in a similar manner to this tutorial, be sure to stop at the end of step 5 to continue with step 1 of this tutorial.

      Step 1 — Configuring Your WordPress Installation

      With WordPress installed, we need to take a series of steps in a variety of configuration files.

      To begin, let’s modify the WordPress configuration, activating the multisite feature. In your command line after logging into your WordPress server, execute the following command:

      • sudo nano /var/www/html/wp-config.php

      Add the following line above the /* That’s all, stop editing! Happy blogging. */ (or similar text) comment on the wp-config.php file:


      /* Multisite */
      define('WP_ALLOW_MULTISITE', true);

      Then, save the file and exit. You can do so by pressing CTRL+S to save, followed by CTRL+X to exit.

      Once done, the WordPress online installation page will be waiting. Access the page by adding /wp-admin/install.php to your site’s domain or IP address (eg. and fill out the short online form.

      Step 2 — Setting Up Multiple WordPress Sites

      Go into your WordPress dashboard and select the section called tools:

      networking setup

      Once you have filled out the required fields, go through the directions on the next page:

      next page

      Create a directory for your new sites:

      • sudo mkdir /var/www/wp-content/blogs.dir

      Next, you’ll need to alter your WordPress configuration. Make sure to place the following content above the line saying /* That’s all, stop editing! Happy blogging. */ or similar:

      • sudo nano /var/www/wp-config.php


      define('MULTISITE', true);
      define('SUBDOMAIN_INSTALL', false);
      define('DOMAIN_CURRENT_SITE', '<b><i>YOUR IP ADDRESS HERE</b></i>');
      define('PATH_CURRENT_SITE', '/');
      define('SITE_ID_CURRENT_SITE', 1);
      define('BLOG_ID_CURRENT_SITE', 1);

      After making all of the necessary changes, log into WordPress once more.

      Step 3 — Setting Up Your New WordPress Site

      After logging into your site again, you will notice that the header bar now has a section called “My Sites” instead of simply displaying your blog’s name:


      You can now create new sites by going to My Sites at the top, clicking on Network Admin, and clicking on Sites:

      create a new site

      Here are a few links to other tutorials that are related to this quickstart guide:

      Source link