echo “Hello Again, World!”;

NOTE: This system has a new page — you can find it at I’ll leave this page up for historical purposes, but it’s closed to new comments. Comments are most assuredly open on the new page.

Greetings and salutations.

This is my second blog, which is here to serve as a repository for the really die-hard geekery that I feel just doesn’t belong in my regular blog. I discuss the reasons in a bit more detail over there, if you haven’t seen it.

I’ve been thinking about this for a few months, and have taken a couple weeks to get things going. The reason setting up this second blog has taken so long, and the reason my main blog has been virtually silent for so long, is that in the process, I did something kind of cool.

Let me step back for a moment. I am a true hacker at heart, in the traditional sense: I love to pull things apart and take a look. To see how they work and how they might work better. I’m also an avid Mac-head, and since the rise of OS X, I’ve been learning the ins and outs of its Unix-like underbelly.

In a nutshell, my computer is highly customized.

A few years back I got a second computer — a laptop — and quickly discovered that while keeping one computer tweaked to prime operation just the way I like it is kind of fun, trying to keep two computers in such a state, and relatively synchronized, is a frustrating exercise in futility.

I also know a good bit of web coding. As I’ve been working with WordPress for a couple years now, I’ve come across a number of good plugins and expansions along the way. Beyond issues involved with installing them, (which is admittedly pretty easy, usually) over time I have to keep up with updates to these — not to mention updates to WordPress itself. From time to time I even delve into the plugin files myself and make improvements….

And I want to put in a second blog? Am I nuts??? Thinking of what a pain it would be to maintain two copies of WordPress, I started looking into the various multi-blog solutions people have come up with. Most of them involve a lot of weird modifications to several files and basically comprise major modifications to large swaths of the WordPress code that are fundamentally incompatible with the regular version.

I am a great fan of what I consider “elegant” coding, which means that the designer does his job with the simplest and most straightforward methodology possible. And I found a very elegant solution to the “multiple blog on one install” question. Allan Mertner came up with something that blew me away with its simplicity and power.

WordPress holds all of its data in a MySQL database, and there is a single file called wp-config.php that holds the database login information. Allen looked at this and realized that if you can change that one file, you can completely replace the blog. With this key realization he came up with a cunningly straightforward multi-blog system:

  1. Replace the standard wp-config.php file with a new version that calls a different configuration set depending on what directory it’s in.
  2. Set up symbolic links that serve as “virtual directories” that all point to the WordPress directory.

Using the example of this site, I have an install of WordPress in my /blog/ directory, and a symbolic link called “nerdaphernalia” (that’s right, you’re soaking in it!) that points to /blog/. The modified wp-config file points to either the blog or nerdaphernalia config file, depending on which of those two directories it thinks it’s in.

So other than a happy user, where do I come in in all this? Well, I made a number of improvements. First, Allan’s system was great, but it required us to install various files in and around the core WordPress files, which for me at least defeats part of the purpose of using a multiblog system in the first place. I’m trying to make updates easier, remember? Updating WordPress generally involves deleting everything but the wp-config.php file and the wp-content folder, and then dropping in the new versions of everything else; but if there are important but non-standard files strewn about, I can’t just do that. I have to remember to go through and preserve those files, and then replace them when they’re done. Add in a few plugins that work the same way, and we have a real hassle.

So first off, I tucked all the files, except for the one modified wp-config.php, into a folder in a safe place. Next I set it up so that the only files that need to be modified by the user are the wp-config.php itself (with settings relating to the blog directories) and the individual wp-config-blogname files for each blog. I streamlined the wp-config file quite a bit, leaving a bare minumum of code in the file that people have to tinker with, and dumping most of it into a file that nobody should have to modify. Toss in some minor fixes, and we are left with a easy but powerful system for running virtually any number of blogs off a single install of WordPress.

I’ve blathered on long enough. Here is the download, including all the files you need (except WordPress itself), and a full set of instructions.

Please Note:

I’ve spent a lot of time working on this system, making it as solid and easy-to-use as possible. If you would like to contribute something to support this site, it is appreciated.


Good luck, enjoy, and I hope people find it useful.

This entry was posted in Webcraft and tagged . Bookmark the permalink.

117 Responses to echo “Hello Again, World!”;

  1. Bryan says:

    Thank you for your insight and code. It’s helped me here create team blogs here at

    One quick suggestion – I’m perfectly happy using one DB for all my blogs – as such, an easier construction was to change wp-config.php to *always* look for mb-config-default.php and then change the hard-coded table prefix name (‘wp_’) to $user

    That just removes a step when I want to add a new blog, and in fact makes it so the only real thing I need to do is edit wp-config.php and add the username there.

  2. Pingback: a square with round corners » Setting up a multiple blogs with a single Wordpress install

  3. Strider says:

    Bryan — Nicely Done! I can’t believe I hadn’t thought of that! 🙂

    Gate — I’ll be the first to admit that the subdomain code hasn’t been thoroughly tested. (That is to say, I haven’t tested it at all. Presumably it’s original author, Allen, did so when he first wrote it.)

    Regarding your problem deleting the default First Post, I can’t imagine what that could possibly have to do with this methodology. Sounds like you’re having database problems to me.

    Did you give your different blogs different databases or table-prefixes?

  4. Gate says:

    First of all, thanks to take a little of your time to answer me.

    For the subdomain I have give up.

    I have one database with two differents prefix.

    here is my code for the blog
    file name : mb-config-aiandmusic.php

    // ** MySQL settings ** //
    define('DB_NAME', 'gate_esourcing');    // The name of the database
    define('DB_USER', '***');     // Your MySQL username
    define('DB_PASSWORD', '$$'); // ...and password
    define('DB_HOST', 'localhost');    // 99% chance you won't need to change this value
    // You can have multiple installations in one database if you give each a unique prefix
    $table_prefix  = 'wp_aiandmusic_';   // Only numbers, letters, and underscores please!

    and for
    file name : mb-config-default.php

    // ** MySQL settings ** //
    define('DB_NAME', 'gate_esourcing');    // The name of the database
    define('DB_USER', '***');     // Your MySQL username
    define('DB_PASSWORD', '$$$$'); // ...and password
    define('DB_HOST', 'localhost');    // 99% chance you won't need to change this value
    // You can have multiple installations in one database if you give each a unique prefix
    $table_prefix  = 'wp_esourcing_';   // Only numbers, letters, and underscores please!
  5. Strider says:

    Gate — check out this comment regarding subdomains. Let me know if it works! 🙂

  6. Gate says:

    Sorry Stephen but it works without subdomain, now all is configured and I have sent my address to several directory so don’t really want to change this now.

    any idea why my search function search my other blog?



  7. Strider says:

    No, I don’t. It might be a problem with the theme you’re using. As a test, switch a blog to the default theme and see if the problem goes away.

    Like the starting posts problem, I don’t see how multiblog might change the search function. Check your theme first and let’s see what happens….

  8. Gate says:

    well, when I’m change the theme, the search seems to search on aiandmusic, but there is an error:

    WordPress database error: [Table ‘gate_esourcing.wp_aiandmusic_post2cat’ doesn’t exist]
    SELECT SQL_CALC_FOUND_ROWS wp_aiandmusic_posts.* FROM wp_aiandmusic_posts LEFT JOIN wp_aiandmusic_post2cat ec3_post2cat ON ec3_post2cat.post_id=id LEFT JOIN wp_aiandmusic_ec3_schedule ec3_sch ON ec3_sch.post_id=id AND ec3_sch.end>=’2007-10-14 00:00:00′ WHERE 1=1 AND (((post_title LIKE ‘%massif%’) OR (post_content LIKE ‘%massif%’))) AND post_type = ‘post’ AND (post_status = ‘publish’ OR post_status = ‘private’) AND (ec3_sch.post_id IS NOT NULL OR ec3_post2cat.category_id!=34) ORDER BY post_date DESC LIMIT 0, 10

    can anyone help me?

  9. Strider says:

    Gate –It sounds as though you’re having problems unrelated to multiblog. The post2cat table disappeared as of v2.3 of WordPress, but something in your site is still looking for it. Perhaps a plugin that needs to be updated? (Is your search the default, or a plugin or something? Are you using the default theme or a third-party theme?)

    Perhaps you should try your luck at the WordPress forums — I’m pretty sure your search issues are not related to multiblog.

  10. Gate says:

    Thank you very much Stephen,. Now all is working thanks to you, it was a problem with my eventcalandar3 plugin.

  11. Strider says:

    Thought so. When in doubt, one of the first things to try is disabling your plugins. if that fixes it, re-enable one by one until it breaks again….

  12. Trey Harvell says:

    After playing around with several different setups suggested on the web for doing this, I managed to come up with my own.

    It does not require symlinks, or special .httaccess edits. Instead you only have to edit the wp-config file. And add a little code:

    Just copy the wordpress files into one folder as per usual install of one blog, and when you edit the wp-config file, make the following changes:

    $web = str_replace(“www.”, “”, $_SERVER[‘HTTP_HOST’]);

    switch ($web) {

    case ‘’:
    // db information for goes here;
    case ‘’:
    // db information for goes here;
    case ‘’:
    // db information for goes here;

    The domains will share the plugin and theme files, but since their selection/activation and each blogs settings are stored db side, it will allow you to make sure that each has its own content, look, and plugins activated. When you update your one I have not tested this exhaustively, so it may break with some plugins, but it shouldn’t.

    Alternatively, if your blog structure is laid out like this: You only have to make one change to the code:

    Replace the first line with $web = $_SERVER[‘HTTP_HOST’];

    Hope this is helpful!

  13. Strider says:

    Trey — It’s a nice methodology, though it might get unwieldy if someone has a _lot_ of blogs (such as a “blog farm” site). I’ve been updating my system, and might just roll aspects of your version into it. Combined with Bryan’s idea there is a LOT of flexibility with that sort of thing.

    The symbolic links, as you observed, are not needed if you’re doing domain-based blogs. They are necessary if doing directory-based blogs, such as I do on this site (/blog/ and /nerdaphernalia/)

    In fact, the more I look at this type of concept, I’m seeing ways to eliminate the need to ever edit the config file, even with the directory-based version that I use.

    The ultimate would not require the user to add any files _at all_, but allow power users the flexibility to use separate config files if they choose to.

  14. Pingback: David’s Technical Musings » Blog Archive » Multi-blogging

  15. David Potter says:

    Funny you should suggest that :-). I’ve been playing around with your solution and when I read Bryan’s simple modification it caused some stray brain cells to fire. I’ve made quite a few modifications to your solution which provide the following features:
    Single configuration file with option to use other config file if you need it.
    Support multiple domains and virtual folders at the same time.

    My solution still requires that you modify the config file for each site. I ended up not using Bryan’s idea to default the table prefix. I’m sure there are other improvements that can be made to this to further reduce the number of changes required to the file system. What would be cool is a plugin model that would allow you to add sites through admin UI.

    By the way, I found that the code that used the mb_config_NF() function didn’t display the message properly. The function needed to declar $mbpath as a global, and the die() function doesn’t take a string.

    Anyway, thanks so much for your good work here.

  16. David Potter says:

    The link to download my changes was broken as I recently moved my blog and the download manager templates needed tweaking. I tested it and it works now. Sorry for the inconvenience.

  17. Strider says:

    Update on the update:

    I’m in final testing of a significant update to this system, including support for directory, domain, and subdomain-based “virtual” blogs. I’ve also cleaned up the setup files and simplified the wp-config a bit.

    Either in this release or soon after, I may include the ability (by default) to have a “no config” setup that simply prefixes the tables based on the current directory (based on Bryan’s suggestion). This would make it work better “out of the box” for non-power users, but allow for individual configurations if needed.

    This has been a long time coming. Sorry for the delay — I should have it up this week some time. 🙂

  18. Stephen,

    This is simply brilliant. I have a need to have one main blog and fifty states blogs that feed into the one. I think your solution will work, but I wanted to run this by you before I attempted to tinker. This is not my art, mine is Raku Clay handmade tiles and conservative thought. I appretiate your artistic use of code to simplify. I was wondering if you would be willing to think this over and give me suggestions if you think this is the way to go. My original site is I am growing the Grizzly Groundswell to have 50 conservative Republican bloggers, one from each state plus a number of Grizzly Groundswell Mayors as Authors from each state as well.

    Essentially, my vision is to have one main site The 50 states sites (ex. Minnesota, North Dakota, California etc.) Each state will consist of one Grizzly Groundswell Governor (editor) and many Grizzly Groundswell Mayor’s who will fill the author’s roster for each states blog. Some may have two, others 35 or more!

    All 50 blogs will hopefully be able to feed into the main Grizzly Groundswell site. (I have not figured out how to do this yet.) But your multiple blogs concept solution should give me

    one main site: Grizzly Groundswell

    North Dakota
    Etc, etc.

    I am currently moving my domains and hosting to Go Daddy and I am setting everything up so there is no pain for my authors, only an updated wordpress to look forward too!

    But I would like to utilize your code and expertise to blow them away!

    Can you help me?

    ~Teddy Bear

  19. Strider says:

    Ted —

    The current download works for this setup:

    and so forth.

    In the next day or so I expect to release version 2 of this methodology. You might want to work with that. It will additionally allow you to do:

    or completely separate domains. I’m working on simplifying the setup still, so you might not need to make 50 separate config files.

    FYI – each blog has a _completely_ separate administration — it’s like a totally separate install of WordPress. As of yet there is no cross-linking of Users, for example. Another person I know of is working on a WP plugin that allows sharing of User tables, but I don’t think it’s “ready for prime time” quite yet.

    Not sure quite what you mean by “feed into the main… site”. the main blog can certainly be made to link to the 50, but I wouldn’t expect direct interactivity. If you want some of the subsidiary blog posts to appear in the main blog, you might look for a WordPress plugin that allows cross-posting. There’s probably something like that out there….

    Stay tuned….

  20. Stephen,

    This is exciting!

    So each blog would be sepperate onto itself? That is pretty amazing! So with on wordpress install, I could host my 51 blogs!

    That is simply exciting.

    Now I have to figure out if that is what my authors want!


    Teddy Bear

Comments are closed.