Hosting multiple blogs on a single WordPress installation

As you can probably tell from this blog, WordPress is my favourite blogging tool. I’ve been using it for a couple of years now, and during that time I’ve been really impressed by it. So when I was recently asked if a single copy of WordPress could be used to power several blogs, I was optimistic that it would be up to the job.

And it didn’t disappoint me…

There are a number of ways you can host multiple blogs with WordPress:

  • WordPress MU (multi-user) – This is system that powers all blogs at wordpress.com, Le Monde, Harvard Univeristy etc…
  • Batch management of blogs with WP-Create and WP-Upgrade – These scripts let you install multiple blogs in parallel, however each one would get it’s own installation.
  • Modifying wp-config.php to choose a different database per hostname. This uses the standard wordpress scripts.

Since I wanted to use a standard wordpress installation, and I didn’t want to install it multiple times, I chose the 3rd option. WordPress stores most of it’s configuration in it’s database, so all you need to do is modify wp-config.php to point at a different database depending on the hostname of the site being accessed:

// Ignore the www. part of a hostname
$host = eregi_replace('^www\.', '', $_SERVER['HTTP_HOST']);

switch ($host) {
        case 'site1.co.uk';
                $db = 'site1';
                break;
        case 'site2.co.uk';
                $db = 'site2';
                break;
        default:
                header("HTTP/1.0 404 Not Found");
                exit();
                break;
}

// ** MySQL settings ** //
define('DB_NAME', $db);    // The name of the database
define('DB_USER', 'user');     
define('DB_PASSWORD', 'password'); 
define('DB_HOST', 'hostname'); 

Simply add the existing database settings code with the code above, and then create a new empty database for each blog you want to host. You will need to run the install scripts for each blog, e.g. http://www.site1.co.uk/blog/wp-admin/install.php

References:

iPhone firmware update fails

If you repeatedly get an error while upgrading your iPhone’s firmware that says something like:

the iphone could not be restored an unkown error occured 1604

Try restarting iTunes and plugging the iPhone into a different USB port. Failing that you might need to try restoring the phone on another machine before syncing your settings from the original machine.

Always look for a voucher code when shopping online

Although we’re not technically in a recession yet, we are certainly in midst of a downturn in the economy and with prices rising and wages stagnating (or even falling in real terms) I think most people are definitely feeling the pinch on their wallets.

However, everyone still needs to make some purchases, and there is one easy way you can save a few percent when shopping online; use a voucher / discount code. It surprised me that some of my friends weren’t aware of this, as I’ve been using vouchers for years to get a discount on anything from pizza to holidays.

Dominos regularly give out vouchers for 20% off online orders, and last year I managed to get 15% off a group holiday to Center Parcs. There were 18 of us, so that amounted to about £200 in savings! Hence why it’s definitely spending a few minutes searching for codes online.

A friend of mine has just launched a new site, which aims to have the largest and most up-to-date selection of voucher codes. They are investing a lot of time into checking all their codes and ensuring that they remain valid, and they publish the expiry date so you know when it must be used by.

It’s a good idea to start looking for codes in advance, as this year I missed out on getting a Center Parcs discount… there were no vouchers available when we booked.

Testing out wordpress for the iphone

This is my first post using my iPhone. I’ve installed the wordpress app and now I’m typing on the phone itself!

First thoughts: it’s great! I was a little concerned that the iphones spell checker wouldn’t work but it does (although not in the post titles).

I’ve tried to attach a photo of brendan so let’s see if that works…