Enable Multi-Site in WordPress

WordPress merging with WordPress MU makes an awesome software package even better. The issue now is, how do you turn on the multi-site functionality? If you are like me and find yourself forgetting that one line of code needed to kick off the setup of multi-site within WordPress. Then you made it to the right place, because for your benefit and mine I have taken the time to write down the steps involved. The first step is to install WordPress so be sure to head over to WordPress.org for the latest version and then do a standard install of WordPress. Once you have WordPress up and running you can enable multi-site in just a few quick steps.

1. Add the following to the wp-config.php

/**   MULTI-SITE SETUP   */
define('WP_ALLOW_MULTISITE', true);

2. Navigate to Tools > Network and choose your install type

You will have to choose what kind of network you want to run. Your choices are either Sub-directory setup or a Sub-domain setup. These choices affect how the addresses of your sites look.

Sub-directory
This configuration means that all your blogs/sites created within WordPress are extensions of your domain. So if you were using the domain myawesomesite.com then your blogs/sites within WordPress would all have domains like:
myawesomesite.com/siteone
myawesomesite.com/sitetwo

Sub-domain
This configuration does require some extra DNS work meaning you will need to setup a wildcard DNS record. With this setup each new blog/site in WordPress becomes it’s own sub-domain of the top level domain that was used to install WordPress. So if you installed WordPress on the url myawesomesite.com each new site’s domain would look like:
siteone.myawesomesite.com
sitetwo.myawesomesite.com

Once you have chosen the setup you want to run enter your network details and hit install.

3. Finish up the network install

There are a few things that you need to do manually to finish the install.

Create the blogs.dir directory
Create a new directory in the wp-content folder called blogs.dir, this directory will be where all your sites uploaded content is stored.

Edit wp-config.php
WordPress will generate some new settings for you to add to your config file. These settings are specific to your network. For the myawesomesite.com setup they would like this:

define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
$base = '/';
define( 'DOMAIN_CURRENT_SITE', 'myawesomesite.com' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

Edit or create the .htaccess file
If you already have a .htaccess file setup then you will just want to edit the area the contains WordPress rules. If you don’t have a .htaccess file go ahead and create one. Now all you have to do is copy in the settings provided by WordPress, save the file and you are done. This is an example of the code generated by WordPress:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [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]

4. Remove the Tools > Network menu option

Once you have your network setup you can remove the menu option simple by commenting out the enable multi-site option in your wp-config.php file.

/**   MULTI-SITE SETUP   */
//define('WP_ALLOW_MULTISITE', true);