echo “Hello Again, World!”;

NOTE: This system has a new page — you can find it at http://striderweb.com/nerdaphernalia/features/virtual-multiblog/. 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.

117 Comments

Pages: « 1 [2] 3 4 5 6 » Show All

  1. #21 | Posted April 19, 2007 at 4:07 am

    The proper php symlinks code for shared hosting users without unix prompt access.

    <?php
    symlink ('/home/userID/public_html/bob',
    '/home/userID/public_html/joe');
    ?>

    there is a space in between, ?php and
    that needs to be removed in order for this code to work. (I need it there so this post would show)
    [no there ain't -- ed]
    this is the same code that is invisible from this previous comment.

    bob is the folder where you install the “real” honest to goodness wordpress files
    joe is a folder that does not exist but will be created after you call this file from a browser.
    Put this file in your root folder, and make your root folder temporarily writable.
    If it works you will see a blank page.

    And in your root folder there you will see the “joe” folder.
    That is actually a symlink.

    userID should be replaced with the proper website name
    Bob and Joe are respectively your default blog folder name, and the clone..

    This can be done again for more clones.

    Thank you again Stephen!

  2. #22 | Posted April 19, 2007 at 4:09 am

    there is still some invisible characters above, but I hope you guys figure it out
    =)

  3. #23 | Posted April 19, 2007 at 4:10 am

    [...] is a wordpress multiplicity of “Journal” yet using a different database [...]

  4. #24 | Posted April 19, 2007 at 9:37 pm

    Mo —

    I think I got the php right. Thanks for that. :)

    The live comment preview isn’t perfect — for that type of code you really just need to use &lt; and &gt; …I think.

  5. #25 | Posted May 8, 2007 at 12:35 am

    Very cool! I just accomplished this for a client’s site and it worked like a charm! Thanks a lot.

  6. #26 | Posted May 10, 2007 at 1:55 am

    Yeah, its fixed now =]

    (my web server burned in an accident after I wrote that update on my new website configuration; thus that dead ping back, haha.. sorry)

  7. #27 | Posted May 16, 2007 at 7:13 am

    [...] Stephen Rider’s updated version of Mertner’s method, which is more cleanly organized and has some code fixes: http://striderweb.com/nerdaphernalia/2006/10/hello-agai... [...]

  8. #28 | Posted May 22, 2007 at 2:06 pm

    This looks like exactly what I need, but my one burning question is — can I test it on a localhost install using XAMPP?

  9. #29 | Posted May 22, 2007 at 8:36 pm

    Panya — I test it myself on a Mac running OS X. As long as you’re running an OS that understands symbolic links, you should be good to go. (That is, some flavor of Unix/Linux/GNU, not Windows….)

    Note: On a Mac, aliases are NOT the same thing as symbolic links!

  10. #30 | Posted May 23, 2007 at 9:00 am

    I actually managed to find a miniprogram that will make symlinks in Windows! Apparently Windows can use and understand them, but it’s not a natively-accessible behaviour.

  11. #31 | Posted May 23, 2007 at 8:56 pm

    So out with it! What’s it called? What’s the web address? :)

    Let me know and I’ll add that to the article above — good information!

  12. #32 | Posted May 24, 2007 at 8:16 am

    It’s called Junction, although I imagine there are other programs out there that will achieve the same effect if you look, and the sole caveat I’ve found so far is that symlinks are ONLY ‘available’ for NTFS file systems — so this technique won’t work on your typical USB drive. It seems to be pretty straightforward, though I haven’t tested it extensively yet.

  13. Natalia
    #33 | Posted May 24, 2007 at 8:45 pm

    I actually need two blogs that will be accessible to two separate user groups but one administration for both. Do I need this plugin or is there something else I should be looking for?

    Thank you!

  14. #34 | Posted May 25, 2007 at 11:46 am

    I believe there is.. [multiply]
    even though multiply is a beautiful and wonderful creation, I believe there was no other option in its installation process other than to edit the core wordpress files.. so if like me that sounds to you like a straining job every time you upgrade wordpress, I would stick to this solution or wordpress μ. (which is also not as widely supported as the normal wordpress)

  15. #35 | Posted May 25, 2007 at 3:13 pm

    Natalia — You might also look at WordPress MU, which is the official multi-user version of WordPress. I believe it allows you to control multiple blogs from a single admin.

    My system on this page very specifically ends up with two completely separate blogs, including separate admin areas.

    [edit: oh, I see mo already mentioned it... :) ]

  16. #36 | Posted June 2, 2007 at 8:48 pm

    It is a great concept. I didnt see any info on whether or not there is a way to run multiple domains or subdomains with this plug in which is what I need. I will download this and see what I end up with. Thanks for the work.

  17. #37 | Posted June 3, 2007 at 10:18 am

    Monty — I never tested it myself, but the original author of this method (Allan) seems to have intended it this way. Try making the folder the same as the subdomain name; thus blog2.example.com should be in (symbolic link) example.com/blog2/

    Please let us know if it works! :)

  18. #38 | Posted June 16, 2007 at 1:49 pm

    I fixed the $mydomain usuage in mb-functions.php.

    In your IF statement you compare $mydomain to $_server['PHP_SELF'] but that does not work. ‘PHP_SELF’ only returns everything after the domain name.

    Instead you should compare $mydomain to $_SERVER['SERVER_NAME']. I have tested this and it works.

    I hope this helps anyone trying to use this script with subdomains. BTW, great script! It has helped me out significantly.

  19. #39 | Posted June 16, 2007 at 3:14 pm

    I’ll definitely check it out Travis — thanks.

    As I mentioned above, I haven’t actually tested that part of the code (it was written by the original author), because I’ve never had a need for subdomains. I appreciate the “heads up” — I’ll make the change when I get a chance.

  20. #40 | Posted July 12, 2007 at 2:46 am

    [...] Stephen Rider’s Multiblog zip file – you can download it from here [...]

Pages: « 1 [2] 3 4 5 6 » Show All