Sometimes we will need to have WordPress with Multisite enabled to have different websites in a single WordPress. For example, a corporate website and an online store. To configure this WordPress feature, simply continue with this tutorial.
In any case, to complete the process successfully, you first need a server with the WordPress image preinstalled. Then you must first configure a domain to access WordPress and then configure an SSL certificate. Without these two procedures, you cannot continue with the tutorial.
Enable multisite in WordPress
First, modify the WordPress configuration file. To do this, you can access the server via FTP or SSH. You need to modify the file wp-config.php and add the following:
define( 'WP_ALLOW_MULTISITE', true );
/* That's all, stop editing! Happy publishing. */
We must add the first line directly above the comment that says "That's all, stop editing! Happy publishing."
Next, access your WordPress and go to Herramientas > Configuración de la red.
Here, select the Subdominios option and then add a name for the network of sites and then an email address for the administrator. To finish, click the Instalar button.
After installing, make the requested changes:
Edit the file wp-config again, and where you previously made changes, add the following lines:
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'tudominio.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
/* That's all, stop editing! Happy publishing. */
In the file .htaccess, you do not need to change anything, since Nginx does not use this file.
After these changes, you will need to access WordPress again, and it will now appear with Multisite enabled.
Add a new domain to the network of sites
After logging in again, go to Mis Sitios > Administrador de la red > Sitios:
Here you can now add a new subdomain:
You must specify the subdomain, the site name, the panel language, and then an email address.
At this point, the problem is that when you try to access tienda.tudominio.com, it will try to connect via HTTP and display a 404 Not Found error. And if you try to access it via HTTPS, it will indicate that the SSL certificate is not valid for this subdomain.
To resolve this problem, access the server again via SSH and edit the Nginx configuration file located at /etc/nginx/sites-enabled/default.
You must modify the server_name parameter and add the subdomain:
server_name tudominio.com tienda.tudominio.com;Then reload the configuration in Nginx:
systemctl reload nginxFinally, create the certificate for your subdomain:
certbotAfter running this command, the following will appear:
Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: tudominio.com
2: subdominio.tudominio.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1 2Since there is already a configuration for the main domain, it will ask whether to replace the configuration and expand it for both domains:
Do you want to expand and replace this existing certificate with the new
certificate?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(E)xpand/(C)ancel: E
Press E to expand.
After creating the certificate, edit the file /etc/nginx/sites-enabled/default again and add the following at the very end:
if ($host = tienda.tudominio.com) {
return 301 https://$host$request_uri;
} # managed by CertbotThis configuration must remain inside the server parameter and must be above the $host configuration for your domain.
Reload the Nginx configuration again:
systemctl reload nginxAnd that's it! Your WordPress Multisite is now running with Clouding's WordPress image. If you need to add another subdomain, simply repeat the entire last process.