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.

11 thoughts on “Enable MultiSite in WordPress 3.0

  1. Hi Pete, great sharing! But can i ask where do you apply this section that was mentioned “Rewrite Rules for Nginx and sub-directory installs:”?
    FYI, i have created “.htaccess” and added the details as mentioned by you but i do not understand the step after this as mentioned in my query above. Would be appreciate if you can enlightened me… :)

  2. Pingback: Getting Ready for WordPress 3.0 | Plugin.com

  3. Is there a hook or action to disable the output that necessitates this?
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
    Running every single image through php is very, very hard on a webserver.

  4. Pingback: WordPress 3.0 Released | Developer's Mind

  5. I am new to the multi site thing. When a user signs up does that go across all the sites or is each one separate, or is it an option to set?

    Thanks

    • You can select permissions on a site-by-site basis for the users. For example, a user can be an admin on one site and a subscriber on another site. You can set up the permission on the Users screen under Super Admin.

  6. uh oh, I just followed these directions and tried to log into my backend and got redirected to domain.com!! It went to a 402 in the middle of the page and then to domain.com. Any thoughts?

    • wow, that was embarrassing. I didn’t change the domain.com to my site. My bad.! Got in the cut and paste mode and couldn’t get out.

  7. I agree with bluesplinter, is there any chance to avoid processing through php every image? That’s what is killing my site!! I have nginx (as proxy reverse) and Apache + mod_php and the only thing that’s putting my servers to its knees on heavy traffic is the images part.
    Thank you!!
    L

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>