How to Set Up WordPress Multisite on Ubuntu 18.04 with Apache Web Server

How to Set Up WordPress Multisite on Ubuntu 18.04 with Apache Web Server

Introduction

WordPress has a feature “Multisite” which enables the creation of a network of sites using the same WordPress installation. This allows for easy creation of websites and blogs on demand. Also as an administrator, you can permit users to create their WordPress sites on demand.

A multisite network is a group of sites sharing the same WordPress installation and could also have the same plugins and themes. Every single site within the network acts as a virtual site without its site directory but has separate media upload directory and separate tables in the database.

Why Set up Multisite Network

 

  1. To allow users to create their own sites on demand
  2. For the admin to easily manage all WordPress sites, including:
  • Installing themes and plugins for all sites at once within one dashboard and installation
  • Making any changes to all the sites at once
  1. To enable a company/organization to have a network of sites, blogs and sub-domain sites within one WordPress Installation.

 

In this tutorial, we illustrate how to set up WordPress Multisite on an Ubuntu 18.04 VPS Server with Apache Web Server.

Pre-requisites

Enable/Activate Multisite Network Feature in WordPress Installation

Edit wp-config.php file

$ sudo vim /var/www/html/wp-config.php

Go to the bottom section and you’ll see /* That's all, stop editing! Happy blogging. */.  Add the following text below that line.

define('WP_ALLOW_MULTISITE', true);

Then save and close the file.

Enable/Activate Apache mod_rewrite

Apache mod_rewrite is essential to ensure the network multisite works properly.

Run the command:

$ sudo a2enmod rewrite

To confirm that Apache mod_rewrite has been enabled, run command

$ sudo apache2ctl -M | grep rewrite
 rewrite_module (shared)

The output “rewrite_module (shared)” confirms that it has been enabled.

Enable/Activate .htaccess

The .htaccess file is very critical to the proper functioning of the WordPress Multisite network and the WordPress permalinks. Later on, we will add directives to the file to enable all these functionalities.

Open the apache config file /etc/apache2/apache2.conf

$ sudo vim /etc/apache2/apache2.conf

Edit the section shown below:

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

Change the AllowOverride to All as shown below: – This makes the WordPress Installation to read from .htaccess and override all other WordPress rules.

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

Save and close the file.

Restart Apache

$ sudo systemctl restart apache2

<<network-setup2.png>>

Enter the required details, then Click Install.

The next page appears as shown below:

<<multisite-config.png>>

Follow the instructions given as follows:

  1. Backup your wp-config.php

    Special Note: It’s usually BEST PRACTICE to backup config files before editing them in case you need to revert back.

    $ sudo cp -p /var/www/html/wp-config.php /var/www/html/wp-config.php.bak
  2. Edit the wp-config.php file
    $ sudo vim /var/www/html/wp-config.php

    Then add the following above the line reading /* That's all, stop editing! Happy blogging. */:

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

    Save and close the file.

  3. Create and edit the .htaccess file
    $ sudo vim /var/www/html/.htaccess

    Then add the following, replacing other WordPress rules.

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
     
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
     
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

    Save and close the file.

Log into your WordPress Admin Dashboard once again.

Go to My Sites > Network Admin > Click Dashboard as shown below:

<<access-multisite.png>>

At the network multisite dashboard, Click Create New Site to start creating your new sites as shown below.

<<network-dashboard.png>>

Then enter details of your new site:

<<network-site-creation.png>>

Indeed, you can create as many sites as you want.

Conclusion

Having set up WordPress multisite, you can now set up your own network of blogs and websites with ease at no extra hosting cost.

Also, it will be very easy for you as super admin to manage all your websites from one dashboard. How cool is that! However, it should be noted even though you can create as many sites as possible, you may be limited by CPU & RAM resources and bandwidth resources from your hosting provider.

 

Check out these top 3 VPS services:

Kamatera
AU$5.92 /mo
Starting price
Visit Kamatera
Rating based on expert review
  • User Friendly
    3.5
  • Support
    3.0
  • Features
    3.9
  • Reliability
    4.0
  • Pricing
    4.3
Hostinger
AU$4.43 /mo
Starting price
Visit Hostinger
Rating based on expert review
  • User Friendly
    4.7
  • Support
    4.7
  • Features
    4.8
  • Reliability
    4.8
  • Pricing
    4.7
Webdock
AU$1.41 /mo
Starting price
Visit Webdock
Rating based on expert review
  • User Friendly
    3.8
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.3
  • Pricing
    4.3

How to Change Common PHP Settings on an Ubuntu 18.04 VPS or Dedicated Server

This article shows you how to change PHP settings on your Linux Ubuntu 18.04 vir
less than a minute
Idan Cohen
Idan Cohen
Marketing Expert

How to Install a Let’s Encrypt Certificate on your Ubuntu 18.04 Dedicated Server or VPS

If you are hosting your website on a VPS server running Ubuntu 18.04, we will sh
less than a minute
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester

How to Install WordPress on Your Ubuntu 22.04 VPS or Dedicated Server

This tutorial will show you how to install WordPress on your Ubuntu 22.04 virtua
less than a minute
Idan Cohen
Idan Cohen
Marketing Expert

How to Host Multiple Websites on an Ubuntu 18.04 VPS or Dedicated Server

This article will show you how to host two or more websites on a single Virtual
less than a minute
Idan Cohen
Idan Cohen
Marketing Expert
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top