One of WordPress's most useful features is WordPress Multisite, which allows you to host multiple websites within a single WordPress installation. It's particularly useful for businesses, organizations, and bloggers who need to manage several separate websites from a single WordPress dashboard.
WordPress Multisite supports two types of network configurations:
- Subdomain-based Multisite: Each website uses its own subdomain. For example, if your main domain is example.com, a site in your network would be accessible at http://site1.example.com.
Subdirectory-based Multisite: Each website uses a subdirectory of the main domain. For example, if your main domain is example.com, a site in your network would be accessible at http://example.com/site1.
WordPress Multisite also allows users to create new websites as needed, while administrators can manage all sites from a centralized dashboard.
In this tutorial, we'll walk you through installing and configuring WordPress Multisite on Ubuntu 18.04.
Prerequisites
Before getting started, make sure you have:
- A Cloud Server running Ubuntu 18.04 with WordPress already installed.
- Root access to your server.
Enable WordPress Multisite
First, you'll need to enable the WordPress Multisite feature by editing the wp-config.php configuration file.
Open the file using the following command:
# nano /var/www/html/wordpress/wp-config.phpAdd the following line near the end of the file, before the line that says /* That's all, stop editing! Happy publishing. */:
define('WP_ALLOW_MULTISITE', true);Save your changes and close the file.
Next, you'll need to enable support for .htaccess files to ensure that your WordPress Multisite network and permalinks work correctly.
To do this, edit the Apache configuration file:
# nano /etc/apache2/apache2.confLocate the /var/www/ directory configuration block and set AllowOverride to All, as shown below:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Save and close the file. Then, restart the Apache service to apply the changes:
# systemctl restart apache2Enable the Multisite Network
Once you've enabled the WordPress Multisite feature, open your web browser and navigate to http://example.com, replacing example.com with your actual domain name.
Log in to your WordPress admin dashboard, then go to Tools → Network Setup.
You should now see the Network Setup option in the Tools menu.
Next, select Sub-domains if you want each site in your Multisite network to use its own subdomain, then click Install.
You should see the following screen:
WordPress will now display the configuration settings you need to apply to enable your Multisite network.
First, open the wp-config.php file:
# nano /var/www/html/wordpress/wp-config.phpAdd the following lines above /* That’s all, stop editing! Happy publishing. */:
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'example.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
Replace example.com with your actual domain name.
Save your changes and close the file.
Next, edit the .htaccess file:
# nano /var/www/html/wordpress/.htaccessReplace the existing WordPress rewrite rules with the following configuration:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
Save the file and close the editor.
Once you've updated both configuration files, log out of your WordPress dashboard and log back in for the changes to take effect.
Create a New Sites in Your Multisite Network
Your WordPress Multisite network is now enabled and ready to use.
To create your first site, open the WordPress dashboard and navigate to My Sites → Network Admin → Dashboard.
You should see the following screen:
Next, click Create a New Site to open the site creation page.
You should see the following screen:
Fill in the required information, including the site's address, title, and administrator email address. Then, click Add Site to create your new website.
To view and manage the sites in your network, navigate to My Sites → Network Admin → Sites.
Your newly created site should now appear in the list, as shown below:
You can also access your new website directly by visiting http://site1.example.com, replacing the example address with your site's actual subdomain.
You should see the following screen:
Conclusion
Congratulations! You've successfully set up WordPress Multisite on your Ubuntu 18.04 server!
You can now create and manage multiple websites from a single WordPress installation, making it easier to maintain your entire network.
You can also install and manage themes and plugins centrally, allowing you to make them available across multiple sites without having to install them individually.