WordPress Multi-Site Installation Guide

      No Comments on WordPress Multi-Site Installation Guide

WordPress is not only a blog platform, it can used for almost any project. It comes with a simple but powerful plugin mechanism which allows you to extend the wordpress platform writing your own plugins or using existing ones.

WordPress is used to power the wordpress.com blogging platform. Using a similar configuration a single wordpress installation can power several websites.

Install WordPress

For the beginning you have to install a simple wordpress installation. Create a folder, create the database, open the site to run the installer. Once done wordpress is installed in the single site configuration.

Enabling Network Installation

First of all you have to manually edit wp-config.php to add the following line, just before the “That’s all, stop editing! Happy blogging.” comment. This line will enable the network configuration option. After adding this line to have to Sign Out and Sign In again.

/* Multisite */
define( ‘WP_ALLOW_MULTISITE’, true );

/* That’s all, stop editing! Happy blogging. */

Network Setup

Once the ‘WP_ALLOW_MULTISITE’ option is enabled, after you Sign Out and Sign In the admin section wordpress will display a Network Setup menu item in the Tools section. When you open this page it will check that the dns is properly configured and it will display a warning if 99random99.multisite.com is not accesible(where multisite is our main domain).

If it this stage you are not able to login again, it might have something to do with cookies. Just open an incognito tab in chrome or firefox and you’ll be able to login.

The Network Setup provides the instructions to add a few more lines in the wp-config.php and to modify the .htaccess file. The wp-config.php will look like this:

/* Multisite */
define( ‘WP_ALLOW_MULTISITE’, true );

define(‘MULTISITE’, true);
define(‘SUBDOMAIN_INSTALL’, false );
define(‘DOMAIN_CURRENT_SITE’, ‘multituna.net’);
define(‘PATH_CURRENT_SITE’, ‘/’);
define(‘SITE_ID_CURRENT_SITE’, 1);
define(‘BLOG_ID_CURRENT_SITE’, 1);

/* That’s all, stop editing! Happy blogging. */

Keep in mind that WP_ALLOW_MULTISITE is used by wordpress to decide if it enable the Network Setup admin screen, while MULTISITE is a different variable. If you consider them the same and keep only the first one you’ll end up having a Database Connection Error.

In .htaccess you have to replace the existing wordpress rules with the following:

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]

Mapping subdirectories/subdomains to domains

The default installation of multisite wordpress site doesn’t support multiple sites on different domains. Luckily we can use a separate plugin which maps the requests made for separate domains to subdomains/subdirectories where different sites are available in wordpress. WordPress MU Domain Mapping is the plugin we are using.

The plugin should first be installed in the same way any other plugin is installed. But remember, plugins in multi-site configurations can be installed only from the site network admin panel.

Once the plugin is installed, move the sunrise.php file from the folder where the plugin was installed (/wp-config/plugins/wordpress-mu-domain-mapping/) to /wp-config/. This file is loaded at an early stage by wordpress and it execute the mapping before the pages are generated. To enable the sunrise mapping you have to add another line(if it doesn’t exists) in wp-config.php:

define( ‘SUNRISE’, ‘on’ );

Each new site added will receive an id and it will be added in wp_blogs. The new id is generated based on the mysql autoincrement field from wp_blogs. If for different reasons you want to start the generation of new ids from other number than 1 you can simple change the autoincrement field using the following mysql query:

ALTER TABLE  `wp_blogs` AUTO_INCREMENT =5001

Leave a Reply

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