Enable MultiSite in WordPress 3.0

WordPress 3.0 signals the merge of WordPress and WordPress MU, and allows you to manage a network of sites in WordPress. In this post, I’ll show you how to enable the Network screen and the MultiSite features in WordPress 3.0. You do not need to complete these steps if you are upgrading from WordPress MU. Follow the instructions here to upgrade from WordPress MU. You will need to perform these steps if you are upgrading from a standard pre-3.0 WordPress install and want to use the MultiSite features or on a new WordPress 3.0 install.

Enable Network Menu

Add the following line to wp-config.php:

define( 'WP_ALLOW_MULTISITE', true );

The Network menu under Tools will not show up until you complete this step.

Create a Network
Network Menu in WordPress 3.0

Log in to the WordPress back-end and navigate to the Network screen under Tools. WordPress allows you to choose between sub-domain and sub-directory based installs for your network of sites. You can choose one or the other, but it’s not easy to change later, so you must decide before you proceed.

Sub-domains:

A sub-domain install allows you to have new sites as sub-domains of your WordPress installation. For example, you can have site1.domain.com and site2.domain.com for a WordPress installation at domain.com. You will need to add a wildcard domain alias for your webserver and a wildcard DNS record for your domain. Matt has a detailed explanation about wildcard DNS records and domain alias here.

Sub-directories:

A sub-directory install allows you to have new sites as sub-directories of your WordPress installation. For example, you can have domain.com/site1 and domain.com/site2 for a WordPress installation at domain.com.

Enable Network

Create Media Directory:

Create a blogs.dir directory under wp-content for all uploaded media files for all sites in the network. You must ensure that the new directory has the correct permissions so it is writable by the web-server (apache user).

Update wp-config.php:

Add the following lines to wp-config.php anywhere above /* That’s all, stop editing! Happy blogging. */

define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true ); //false for sub-directory install
$base = '/';
define( 'DOMAIN_CURRENT_SITE', 'domain.com' ); //replace domain.com with your install
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

Update/Create .htaccess:

Create a file named .htaccess in the root WordPress directory and add the following:

Apache and sub-directory installs:

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]

Apache and sub-domain installs:

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

# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule . index.php [L]

Replace all WordPress related .htaccess rules with the ones above if the file already exists.

Rewrite Rules for Nginx and sub-directory installs:

  #on server block
  ##necessary if using a multi-site plugin
  server_name_in_redirect off;
  ##necessary if running Nginx behind a reverse-proxy
  port_in_redirect off;

  rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
  if (!-e $request_filename) {
   rewrite ^.+?(/wp-.*) $1 last;
   rewrite ^.+?(/.*\.php)$ $1 last;
   rewrite ^ /index.php last;
  }

Return to the WordPress back-end. You will have to log-in again and now you’ll see a Super Admin menu item. You can manage your network of sites from this menu.

Upgrading WordPress MU 2.9.2 to WordPress 3.0 (beta) with MultiSite

The main feature of the WordPress 3.0 is the merge of WordPress MU. However, upgrading from WordPress MU to WordPress 3.0 (beta 2) is not an automatic single-click process. In this post, I’ll cover upgrading WordPress MU 2.9.2 to WordPress 3.0 (beta 2).

  1. Replace WordPress Files:
  2. Download and unzip the latest version of WordPress 3.0 (beta 2). Delete the wp-admin and wp-includes folders. Upload the unzipped files to the server, overwriting the old files. Ensure that you overwrite all the files and pay attention to the wp-content folder. You must overwrite the files in this folder and not replace the folder with the new one since it contains the themes and plugins.

  3. Update WordPress:
  4. Log in to the WordPress back-end and follow the link to the Update Network screen to update all sites(blogs) in your network.

  5. Update wp-config:
  6. WordPress encrypts cookies but you must add NONCE_SALT code shown at the top of the admin area to wp-config.php. For example: define( 'NONCE_SALT', 'a<u3S[ g<.4I)#p^-iy?sbb3JPu+W~-Zk|aPLMN[TvoiHIKGI_bbB-h?iliBb2ra' ). This code will be unique to your installation. Add it above the line that says: /* That's all, stop editing! Happy blogging. */

    define( "WP_USE_MULTIPLE_DB", false );
    
    define( 'NONCE_SALT', 'a<U3S[ g<.4I)#p^-iy?sbb3JPu+W~-Zk|aPLMN[TvoiHIKGI_bbB-h?iliBb2ra' );
    
    /* That's all, stop editing! Happy blogging. */
    
    /** Absolute path to the WordPress directory. */
    if ( !defined('ABSPATH') )
    	define('ABSPATH', dirname(__FILE__) . '/');
    
    /** Sets up WordPress vars and included files. */
    require_once(ABSPATH . 'wp-settings.php');

  7. Update Rewrite Rules:
  8. The wp-content/blogs.php file was deprecated in WordPress 3.0 and you must update the rewrite rules to use wp-includes/ms-files.php. Delete wp-content/blogs.php and change it to wp-includes/ms-files.php in .htaccess:

    RewriteEngine On
    RewriteBase /
    
    #uploaded files
    RewriteRule ^(.*/)?files/$ index.php [L]
    RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
    RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L]
    
    # add a trailing slash to /wp-admin
    RewriteCond %{REQUEST_URI} ^.*/wp-admin$
    RewriteRule ^(.+)$ $1/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule . - [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]
    
    <IfModule mod_security.c>
    <Files async-upload.php>
    SecFilterEngine Off
    SecFilterScanPOST Off
    </Files>
    </IfModule>
    

    wpmu-settings.php was also deprecated in WordPress 3.0 and can be deleted.

You should always backup your databases before attempting to upgrade WordPress. If you are not sure how to backup your database, you can find complete instructions in the WordPress Codex.