Installing WordPress MU in LEMP stack


WordPress MU is a feature in which we can run multiple wordpress sites using only a single wordpress installation. That means, the users, themes, plugins will be common, but the contents will be different for different sites. Lets consider, we install a wordpress which is accessible from this link:-

http://example.com

Now, if we enable WordPress MU feature then we can create the following different sites:-

Option 1: Sites under Sub-Domain

http://site1.example.com
http://site2.example.com
http://site3.example.com

Option 2: Sites under Sub-Directory

http://example.com/site1
http://example.com/site2
http://example.com/site3

and so on.

We can redirect all of the above links to different domain also using WordPress MU Domain Mapping plugin.

How to activate WordPress MU feature?

Step 1: To activate this feature in a regular wordpress site, add the following line into wp-config.php at the end.

define( 'WP_ALLOW_MULTISITE', true );

It will add additional entry into “Settings” tab of WordPress dashboard. Click “Network Setup“.

Step 2: From “Network Setup” we will get a piece of code which is to be inserted into wp-config.php

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

Step 3: In case you are using Apache server, then add the following into .htaccess

RewriteEngine On
RewriteBase /wordpress/
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]

If you are NginX, then edit /etc/nginx/sites-available/example.com.conf and add the following code into the configuration file:

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}

Step 4: Now restart Nginx service and access your wordpress site. You can create as many sites you want from “My sites” -> “Network Admin” -> “Sites” -> “Add New”.

Hope the above configuration is useful for installing WordPress MU successfully.

,

One response to “Installing WordPress MU in LEMP stack”

Leave a Reply

Your email address will not be published. Required fields are marked *