Moved to: WoodyHayday.com
Woody Hayday

Fresh Ideas

Hi there! This is my old blog, I don't hang around here much.
You can now find me trying to mix things up here:
Visit WoodyHayday.com Subscribe To My Email List

Multiple WordPress blogs from 1 instance / 1 wordpress folder to maintain

WordPress is a victim of its own success, but its no victim. It is huge. Millions upon millions of people use wordpress to power their blogs (like this one for example) to make money and to have their voice present on the internet. It has become a first stop for a huge host of people making their way online and is often one that leaves such a positive impression that it never leaves that same user. Its free, its slick, its efficient, its easy…literally I have nothing but good things to say about wordpress and the people that support it. I could spend hours applauding the democratisation of tools that is wordpress and discuss how its helped the internet blossom and why its so key to understanding the web today but that’s not what this post is about. If you haven’t already got a wordpress blog then I would suggest you get one, either for free at wordpress.com or from wordpress.org (the latter if you have your own hosting) – and once you have one you might soon realise the huge benefit of having 2, 3, 4 or more wordpress blogs. These are real benefits.

The question then comes after you have 30 wordpress blogs on the go, various niche market’s blogged too or personal sites about cats or what have you, what then? Updates then. WordPress do update fairly regularly, they aren’t the slow moving behemoths some other companies are because they are open source, and that’s a good thing. Anyway maintaining 30 copies of wordpress is actually a lot easier than it sounds, an update is usually nothing more than 10 minutes uploading the new wordpress files over the old ones via FTP. But say you had a little project where you wanted to create a few more wordpress blogs. For the sake of this post lets say you wanted 90 blogs. 90 WordPress blogs installed on an average web host (I suggest 1and1) is not a big deal. It can be as big a deal as you make of it but in your pursuits and interests online its potentially likely to crop up.

You can run 90 wordpress blogs (or 1000 etc.) from 1 instance of wordpress. That is 1 wordpress folder on your host serving to 90 blogs at blogsite1.co.uk, blogsite2.com etc. thats nothing new – I am sure the quicker off the mark or longer in the tooth of wordpress users have been doing it for a while, but somehow I missed this up until I got past the 30 blog mark and so I thought its about time I looked at the option of hundreds of wordpress-blogs running from 1 folder, a project has come up. The reason this works by the way is the wonderful way (take not web developers) that wordpress splits its config files and its database. The only file in the wordpress files you upload to your blog that contains any site specific data is the config file, which pulls everything from the database.

On the preface there are both good and bad things about doing this with word press, here are the pro’s and con’s as I see them pre-project.

Pros

  • Single central wordpress folder  – 1 wordpress folder to update periodically
  • File size – rather than using up 4mb per wordpress install, this method uses 4mb per x number of wordpress installs, although space isn’t an issue really in current web hosting
  • Plugins and themes only need to be copied once – they can effectively be shared
  • Easier to backup – backing up files of wordpress blogs is pretty pointless apart from wp-content (uploaded images, themes, etc) – putting all your blogs in one basket means backing up the whole lot is a breeze, 1 folder not 90!
  • WordPress database is seperate – you could potentially run all the blogs from 1 database too – (capacity dependant) – as wordpress allows table prefix’s
  • Adding a blog can be automated 😉 – replicating the first wp database from an install can mean tons less setup work

Cons

  • Permalink structure may have to be the same? *not 100% on this one and havent tested but there may be issues with permalink setups across multiple blogs as htaccess is shared*
  • Other .htaccess differences – because you will effectively only have 1 .htaccess file for all domains pointing to this folder, this puts all that custom .htaccess code out of the window
  • Flip side of themes being easy to install is that editing one theme will lead to all blogs using that theme to notice the change, fine if your blogs are stable in design but multiple versions of the same theme will be required if you want to tweak these on a blog specific level, which could make for a messy confusing setup if not through through
  • If you are running a network of blogs and want to stay under the radar or just want the sites to be as different as possible – by nature of single resource they will leave footprints unless you are aware and make sure you do things like rename folders for themes non-sequentially etc ( or maybe don’t be paranoid :p )
  • Centralising the files for all domains/sites/blogs does mean this folder on this box does then become a single point of failure, loose/break this and the whole of your blog network/project is down. Probably not such an issue with stable hosts these days
  • As previous point if you do update, change a file or accidentally delete anything it does effect every site – its a risk but not a big one just be careful!

Limitations

  • Unsure about .htaccess but presume custom rewriting becomes a pain as all sites share a file
  • There will be a limit as to how many blogs you can run off a single install. It’s probably thousands though – if you had 30,000 sites for example – the file which points the install to the right database tables would become bloated

How to run tens, hundreds or thousands of wordpress blogs from 1 instance – install wordpress once for hundreds of blogs – without MU.

  1. Install wordpress into a folder on you hosting (download latest from wordpress.org and then upload via FTP/copy across network)
  2. Get your database details together, you will need Database Name, Database Username, Database Password and the Database host for each of the databases you are going to host wordpress tables in
  3. Install a single blog using the normal method – point a domain at the folder, go to that domain and follow the wordpress wizard, entering your database connection details and this blogs title.
    1. Go through this newly installed blog and commit any changes that you will want duplicated throughout the new installs – delete the “hello world” post/default wp links for example.
    2. Imagine this like creating a ghost image for a network of pc’s – you want to make a bare bones default wordpress setup so you can replicate this onwards without having to redo it.
  4. Happy with  your ghost blog setup? go to your phpmyadmin (assuming you have it) and export all the tables for this blog into SQL.
  5. Open that SQL into your favourite text editor, in this case I am using Dreamweaver because I like its find+replace.
  6. You will need to do several find + replaces here, but by doing this you can literally clone a wordpress installation – (works as at 2.9.1 anyway) – this is great for mass distribution (This is quicker than installing and can be automated)
  7. For example if your site was “harrysblog1.co.uk” with a title of  “Harrys Blog 1” then do a find and replace for “harrysblog1.co.uk”, switching out the new domain to be added, same with title’s, users, post’s etc. This way you could clone a wordpress site and switch out words…you can change the table prefix this way too.
  8. Run this newly modified SQL on whatever mysql database you want to run the blog from (could be same one if you mass replaced the table prefix’s)
  9. Alter your wp-config.php file very simply:
    1. Open it up and put a bit of logic which basically says “what domain am I loading from, ah this one – use this DB and this table prefix” – This logic can be as simple or as complex as you want it to be – I kept mine short and sweet with literally:
$thisDom = $_SERVER[‘HTTP_HOST’];

if ($thisDom == “www.specificDomainWhatever.co.uk” || $thisDom == “specificDomainWhatever.co.uk”){ $useDB = 1; $table_prefix = “specificDomainWhatever_”; }

if ($useDB == 1){

define(‘DB_NAME’, ‘xxx’);

/** MySQL database username */
define(‘DB_USER’, ‘xxx’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘xxx’);

/** MySQL hostname */
define(‘DB_HOST’, ‘xxx’);

/** Database Charset to use in creating database tables. */
define(‘DB_CHARSET’, ‘utf8’);

/** The Database Collate type. Don’t change this if in doubt. */
define(‘DB_COLLATE’, ”);

}

*note this is just how I did it, there are other ways – the code works but was just to test the theory – when upscaled to a network of xxx or x,xxx sites this is automated quite easily

*note2 I am having to cut this post short but if anyone has any questions or wants to know more/help on replicating wordpress or multi blog – 1 wordpress instance installs let me know in the comments

References

Striderweb – this post pretty much explains the theory, a bit like this post – but I actually happened across it after writing the post – well worth reading if your going to do this – Stephen Rider has made a great plugin that will do everything you want it to do as above, I winged it and just modified the wp-config which simply worked in my case so personally I didn’t use it, but no doubt its probably worth a try if  you want a more deep solution.

Woody Hayday
9a Holywell Hill

Hi Jo

I have just found out that I will be away to thailand in the beginning of march and as my 6 months of tenancy is up in feb (08th) I was wondering how it worked with regards to rolling contracts?

I would like to move out just before

This entry was posted in Affiliate Marketing, PHP, Transactional SQL, Web Development, Web Technology, Wordpress. Bookmark the permalink. Both comments and trackbacks are currently closed.

2 Comments

  1. Posted January 26, 2010 at 6:03 pm

    Woody,

    Awesome article. You might really enjoy this read too.

    http://robkerry.co.uk/blog/micro-site-seo-hosting.html

    Rob Kerry takes it to the next level by adding in some phproxy re-writes allowing you to have 1 solid server serve every site. Much faster and more stable. I used this with success back in the day. All my future projects are now a lot more legit and less shady, but if you are building your site network this rocks. I would definitely use this on shared hosts and less free hosts, but drop like a few bucks for the basic hosting plans across 3-10 small hosting companies and start rolling.

    Also make sure to vary your registrants if you are automating stuff. 🙂

    Ps. One of the biggest things you can’t skimp on is hosting. Invest in a good server for your serious projects. Other side projects can be on shared stuff.

    Pss. If you are rocking 100+ domains, move them to Moniker and ask for a discount. I get domains with private whois for under $9/year.

    Psss. Can you bump the line height/font size up on your content column. Had to do in firebug, would make it a lot easier to read ;).

    Keep rocking the Mate 😉

  2. Posted January 26, 2010 at 7:46 pm

    Hey Nick,

    Cheers for stopping by!

    Rob Kerrys’ way looks useful, depending on size of the project – Definitely not worth skimping on the hosting though, admittedly this is on shared hosting right now but thats a lazy logistics issue…

    Less shady things eh? You still got any remnents left of the old days ;)? – what’s your current few projects then? ones you don’t mind sharing?

    Currently rocking 100’s of domains, .co.uk’s are only costing me just over £2 though but proxy whois is extortionate with current supplier. Will check Moniker out.

    Site will get a bit of a redesign soon, stock wordpress theme has served me well but its just been temporary!

    Just tried a glass of good red / mate….doesnt taste half bad without any algave/sugar too!

Woody Hayday

Comments Archive

Hi there. This is my old blog and it's archived, so you can no longer post new comments on this post (Multiple WordPress blogs from 1 instance / 1 wordpress folder to maintain).

Read my new blog about writing software and stories at WoodyHayday.com

The New Blog
WoodyHayday.com
A Quote..
"A man who has not passed through the inferno of his passions has never overcome them. They then dwell in the house next door, and at any moment a flame may dart out and set fire to his own house."
C.G.Jung
Old Random Projects
    © Woody Hayday 2008-2024