How to Create a Network of Site using WordPress Multisite Feature

Posted in Tutorials

Tweet This Share on Facebook Bookmark on Delicious Digg this Submit to Reddit

Starting with WordPress 3.0, you have the ability to create multi WordPress sites with only one WordPress install.  This was formerly known as WordPress MU (or WordPress MultiUser).  But now it is baked into WordPress 3.0.

You should read “Before You Create A Network” in the WordPress Codex to determine if in fact a using Network of Site is the right choice.  Sometimes it might be better to have multiple instances of WordPress installs instead.

You will  have to decide between domain-based (sub-domain) and path-based (sub-directory) installations of Multisite.

A domain-based multi-site would be if you want to have a site at …

http://blog1.example.com

and another at …

http://blog2.example.com

In this tutorial, we will do an example of a path-based multisite with one blog site at …

http://example.com/

and another site at …

http://example.com/secondblog

Step 1: Install regular wordpress at the root (or the parent directory of blog1 and blog2).  During installation, good idea to  use a database prefix other than the default “wp_”.

Step 2:  Setup pretty permalinks first if you want that  (and you should).

Step 3: Deactivate all active plugins

Step 4:  Edit wp-config.php to add this line …

define( 'WP_ALLOW_MULTISITE', true );

Step 5:  This enables the new menu “Tools -> Network Setup” in the WordPress dashboard.  Go there now.

Step 6:  You will come to the “Create a Network of WordPress Sites” screen.  If allowed, you will be given a choice between domain-based (sub-domain) and path-based (sub-directory) installations of Multisite.  But if you installed wordpress in a directory, then you won’t have that choice because then you can only do path-based installation of Multisite.  Make that mod_rewrite is enabled on your server.  Click the “Install” button at the bottom of that page.

Step 7:  You will be directed to a page with instruction that is specific for your install and host.  In instructions requires alteration of  wp-config.php and .htaccess files.  So you should back up these files before proceeding.

Step 8:  Then you have to re-login.

Step 9:  After re-logging in go to “My Sites -> Network Admin -> Sites -> Add New”.  You will fill in the path of your sub-site.  In our case it will be “secondblog”.   You will fill in the admin email for this secondary site.  Wordpress will email the admin password to the email address provided.

It can be the same or different admin as the first blog.  Log out and log into the second blog to see that it works.

For each blog a whole set of WordPress tables is created in the same database.  For example, “wp_posts” is the main blog’s posts table.  “wp_2_posts” is the table for the secondblog.  There are a few extra tables added to support multi-site.  For example, the table wp_blogs lists all the blogs.  And wp_site tell you which is the main blog.

Step 10:  At this point, you can keep on adding more blogs such as “thirdblog” that is on the same level as “secondblog”.

Note that no extra directory “secondblog” or “thirdblog” is created.  It is all run off of the main WordPress install.  The magic is done via mod_rewrite.

But then where is the images and content stored?  For the main blog, it will be in wp-content/uploads as usual.  For the secondblog, it will be in wp-content/uploads/sites/X/   where X is the blog number.

And other little details like that can be found on multisite administration here.