Combining Multiple WordPress Installs with WordPress 3.0

One of the features of WordPress 3.0 is it combines into the core the MU branch. WordPress MU is what powers multi-blog sites like WordPress.com and while it includes all that is needed to allow users to sign up for their own blogs, you don’t have to allow this.  Even if you just have a few WordPress sites (and given that it makes a fine basis for a CMS, I assume many people may have) running them on the same installation means update once, themes and plugins can shared, and a common user base maintained.  The only thing that put me off before was that some plugins were not compatible with MU.

If you’ve got WordPress 3.0, you’ve already got MU.  It just needs you to change one line of wp-config.php!  If you’ve already got sites up and running, and on a different domain, there are a few more steps involved.  Here’s what I did, with some links to site where I found help, like this great overview.

The Scenario

I have upgraded littlestorping.co.uk to WordPress 3.0 and I have some sites on other domains I’d like to run off the same WordPress install.

Enabling Multi-site in WordPress

The implications of switching multi-site on are significant enough that the WordPress folk don’t want people accidentally flicking a switch in settings, so you have to change wp-config.php.  But all you have to do is add the line:

define('WP_ALLOW_MULTISITE', true);

You can get things going by visiting the Tools menu and selecting Network. I found helpful information at WPbeginner. When switching on you can select whether new sites appear in subdirectories or subdomains. I wasn’t given the option of subdirectories (something to do with my setup) but I wanted subdomains anyway.  I then got told by WordPress I should change my site’s URL from www.littlestorping.co.uk to littlestorping.co.uk. I wasn’t clear why, but I think it was because leaving the www would mean that the subdomains would be example.www.littlestorping.co.uk rather than example.littlestorping.co.uk.  I wasn’t wild about having to do that, however www.littlestorping.co.uk redirects to littlestorping.co.uk anyway, and some people (eg. Matt Mullenweg) prefer to lose the www anyway.  So I’ve changed, but I suspect that one or two plugins and related services may still be affected.

Wildcard DNS

For the subdomain thing to work, you need to have Wildcard DNS enabled.  I thought I didn’t have Wildcard DNS (my host’s FAQ said – need Wildcard DNS?  Just ask!).  It turns out all I needed to do was create a new subdomain *.littlestorping.co.uk and the rest took care of itself.  I’d like to point out here, that my hosts got back to me in less than one hour on a Sunday.  I have a very low cost package with them, and their email support is outstanding, so I’d recommend without reservation checking out 5quidhost if you’re looking for someone to host your WordPress site.

If you’re not sure if you’ve got wildcard DNS, pick a subdomain you haven’t set up, eg. brillig.littlestorping.co.uk. If it’s on you’ll be redirected to littlestorping.co.uk but if not you’ll get a server not found message.

Having set activated the “network” in WordPress, you should see a new Super Admin menu above your dashboard.  This is where you can control all your sites!  I went to Super Admin > Sites and under add sites specified test as the subdomain in the address, stuck a title in, hit the button, and created a test site at test.littlestorping.co.uk.  It shows up by default in the new TwentyTen theme. Cool!

Preparing to Move

The next step is to bring your existing site that is currently hosted in its own install into this one.  So, for example, www.example.co.uk will become example.littlestorping.co.uk in the new install.  Later we’ll give it back the www.example.co.uk, but for now we’re going to have to put that on hold.

In my case, www.example.co.uk is an add-on domain.  The site itself is stored in a subdirector /example, and is accessible at littlestorping.co.uk/example, and example.littlestorping.co.uk as well as www.example.co.uk.  Because in the WordPress settings, I’ve set the URL as www.example.co.uk, as soon as you start using the site, the domain will switch to www.example.co.uk.  The next step is to go, in the WordPress install for this site, to Settings > General and change the site address to the equivalent of littlestorping.co.uk/example.  For now this means that it’s still accessible via all three addresses, but all its internal links now point to the subdirectory version.  This is important, because we’re going to switch off both www.example.co.uk and example.littlestorping.co.uk for the moment, and we still want the site to function.

This is probably a good point to export your the site you’re moving.  In its WordPress install go to Tools > Export and download the export file.

Moving

In your hosts’ CPanel or equivalent, remove the add-on domain www.example.co.uk.  Then, if necessary, remove the example subdomain.

In your new WordPress 3.0 install, where all your sites are going to live together, go to Super Admin > Sites and add a new site with example as the subdomain, ie. at example.littlestorping.co.uk in my example.  You’ll need to set the title and subtitle to match the site you’re moving, WordPress won’t do this for you.  Then in the list of sites, for example.littlestorping.co.uk click on Backend.  This changes everything below the Super Admin menu to refer to the site you’ve just created.  If you click “Add Post” now, it will be added to example.littlestorping.co.uk.

Go to Tools > Import and click on WordPress.  Locate the file you exported before and pull it in.  Have the import copy all your files – this will make your master WordPress install go and fetch them and manage their organisation.  You will therefore be able to safely delete /example when you’re done.

Set the right theme and install and/or enable the appropriate plugins for the site, and that should be it.  You can see the migrated site at example.littlestorping.co.uk and the old site at littlestorping.co.uk/example and compare them to check it’s all worked.  If so, it’s safe to delete /example, and the old site’s tables in your database.

Domains

The final step is to get www.example.co.uk pointing back at our site.  We will need to get a plugin for this: it’s WordPress MU Domain Mapping (well, you don’t need a plugin, but it makes life easier).  Installing this is slightly more complicated than usual: sunrise.php needs to go into /wp-content, and another edit to wp-config.php is required to add the line define('SUNRISE','on'); as described in the plugin’s installation instructions.

We’ll also need to park our domain with our host.

Then in the master WordPress install, go to the Backend for example.littlestorping.co.uk and within it, to Tools > Domain Mapping. This is the place where you can enter your domain: www.example.co.uk (you can enter a primary domain and as many others as you like, for example I also added example.co.uk).  That should do it!  Your site URL gets updated and you should now find whether you go to example.littlestorping.co.uk or example.co.uk you get redirected to www.example.co.uk as soon as you start using the site.

That’s It

More or less.  I only had a couple of problems with this, it was a very smooth process and has simplified managing my sites. Most of the menus for either site are unaffected – it’s just the Site Admin menu that you’ll see (if you are one!) and the Network Activate button on plugins.  If you have even just a couple of WordPress sites, I would recommend combining just to simplify maintenance.

About Simon Wood

E-learning officer, lapsed mathematician, Doctor Who fan and garden railway builder. See simonwood.info for more…

Leave a Reply