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
- To allow users to create their own sites on demand
- 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
- 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
- Ubuntu 18.04 VPS Setup (visit HostAdvice’s VPS reviews for the best VPS providers)
- Already Installed LAMP. If not yet, follow instructions in our tutorial: How To Install Apache, MySQL & PHP on an Ubuntu 18.04 VPS or Dedicated Server
- Already installed the latest version of WordPress (Version 4.9.7 at the time of this publication). If not yet, follow instructions in our tutorial: How to Install WordPress on Your Ubuntu 18.04 VPS or Dedicated Server
- A non-root user with root (sudo) privileges
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:
- 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
- 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.
- 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:
- Click here to get the best wordpress hosting specialized for wordpress.