One of the best features of WordPress is WordPress Multisite that allows you to host multiple websites on a single WordPress installation. A WordPress multisite is used by blogs and businesses who need to host separate websites but manage them under one dashboard.
There are two types of WordPress multisite:
- sub-domain multisite: If you host WordPress sub-domain multisite on domain example.com, you will have an address of http://site1.example.com.
- sub-directory multisite: If you host WordPress sub-directory multisite on domain example.com, you will have an address of http://example.com/site1.
WordPress multisite allows users to create their own site on demand and manage all sites at once within one dashboard.
In this tutorial, we will show you how to set up WordPress Multisite on Ubuntu 18.04.
Prerequisites
• A server running Ubuntu 18.04 with WordPress installed.
• A root password configured on your server.
Enable WordPress Multisite
First, you will need to activate WordPress multisite features. You can activate it by editing the file wp-config.php:
# nano /var/www/html/wordpress/wp-config.php
Add the following line at the end of the file:
define('WP_ALLOW_MULTISITE', true);
Save and close the file when you are finished.
Next, you will need to enable .htaccess file for the proper functioning of the WordPress Multisite network and the WordPress permalinks.
You can do it by editing the file /etc/apache2/apache2.conf:
# nano /etc/apache2/apache2.conf
Change the 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 apache2
Enable The Network
Once WordPress multisite feature is enabled, open your web browser and type the URL http://example.com. You should see a new item, labeled Network Setup, under the Tools menu.
Next, choose Sub-domains if you want to host multisite in sub-domain and click on the Install button. You should see the following screen:
Next, you will need to use above configuration to enable the features for creating a network of sites.
First, edit the file wp-config.php:
# nano /var/www/html/wordpress/wp-config.php
Add the following lines above the line reading /* 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);
Save and close the file then edit the file .htaccess:
# nano /var/www/html/wordpress/.htaccess
Replace all the lines with the following:
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 and close the file. Once you have done, log out and log in from your WordPress dashboard again to activate the changes.
Create a New Sites in the Network
At this point, WordPress Multisite Network is fully enabled.
Next, go to the WordPress dashboard and click on the My Sites -> Network Admin -> Dashboard. You should see the following screen:
Now, click on the Create a New Site button. You should see the following screen:
Provide all the required details and click on the S Add Site button to create a new site.
Now, click on the My Sites -> Network Admin -> Sites button. You should see your newly created site in the following screen:
You can also see your newly created site using the URL http://site1.example.com. You should see the following screen:
Conclusion
Congratulations! you have successfully deploy WordPress Multisite on Ubuntu 18.04 server!
You can now set up your own network of blogs and websites easily. You can also install new themes and plugins on all your network sites at once.