Virtual Multiblog for WordPress

<?php echo "Hello Again, World!"; ?>

Note: If upgrading to VMB 2.5 from a previous version, please read the upgrade instructions.

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. When I realized the need for a second blog, installing it ended up being a longer process than i anticipated, and I thought I would share the fruits of my experience.

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. Allan 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 the root web directory, and a symbolic link called “nerdaphernalia” (that’s right, you’re soaking in it!) that points back to the root. The modified wp-config file points to either the default 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 greatly streamlined the install process. At a minimum, the user only need edit a single configuration file, autoconfig.php. If desired, the various blogs can each have individual config files, but it’s no longer necessary.

I’ve added user-accessible functions (and the really handy VUSER constant) that can be used in themes and plugins. I’ve added the ability to customize the location of the configuration files, so the security-conscious can move them entirely out of the Web directories if they wish. Overall, we are left with a easy but powerful system for running virtually any number of blogs off a single install of WordPress.

Install instructions are included with the download. Still have questions? Check out the readme and the FAQ. (Note: Sometimes the readme will list a higher version than the download. That happens if I have a development version installed.)

User “JZ” is selling written instructions for installing the system. (Please Note: I have not even seen his instructions, I’m just letting you all know.) More info in this comment.

…And if the directions are worth money to you, perhaps the actual software is worth something as well?

Download

Here’s what you’re really looking for: the download link. Have at it!

Virtual Multiblog v2.6.2

History/ Acknowledgements

For a detailed history, please see the readme file in the download.

Many of the improvements to version 2 were based upon or inspired by commenters to my blog. To them, and to everyone who has sent comments, I am grateful.

Good luck. Have fun.

684 Comments

Pages: « 122 23 24 25 26 [27] 28 29 30 31 3235 » Show All

  1. #521 | Posted June 8, 2009 at 3:27 am

    Ok, a few more data points:

    I turned on VMB diagnostics and every time I load up one of my site’s pages, I get the same VMB diags in the PHP log file, repeated multiple times seemingly dependent on what type of WP page was called (index/category/single entry/etc.)

    The only thing that seems out of place is that in the PHP log, my VMB_URL’s value is “VMB_URL”.

    However, in the WP Admin -> Multiblog page, it seems messed up. Its value is http://domain.com/absolute-path-to-multiblog-dir/

    Hopefully this generates some ideas. Also, where would be a good place in the VMB code to stick in some debug lines? Or perhaps some timing wrappers?

    Thanks!

    _Khalid

  2. #522 | Posted June 8, 2009 at 7:47 am

    RE the diagnostics: It appears WP hits wp-config.php twice with each page load. I’m not sure why. Thus, in my tests, I get the diagnostics in my logs two times every time I load a page.

    You get VMB_URL = VMB_URL because the diagnostic is being called before that constant is set, so PHP is apparently treating it as a string. Note that you can also set it manually. As for the path being wrong — the code that determines it is a bit sketchy, but the URL isn’t terribly important to the system.

    Setting constants via $vmb_const shouldn’t slow anything down. That array is there so that you can set something in the autoconfig and then override it in a blog-specific config.

    Here’s a thought — go into wp-config.php and set $vmb_core_only to true. That will eliminate some of the code that runs.

    Not sure where best to place “tracking” code — probably in vmb-init.php somewhere. In that file look for the code that says:

    require_once( ABSPATH . ‘wp-settings.php’ );

    That is where VMB hands things off to the basic WP system.

  3. Robert
    #523 | Posted June 8, 2009 at 9:22 am

    Pardon me for interrupting.

    “RE the diagnostics: It appears WP hits wp-config.php twice with each page load. I’m not sure why. Thus, in my tests, I get the diagnostics in my logs two times every time I load a page.”

    Is this isolated to KJH, or is it with every installation of VMB ?
    If there is anything I can do, testing, checking, let me know.

  4. #524 | Posted June 8, 2009 at 10:11 am

    Robett — i double-checked, comparing normal WP to WP under VMB. There is no difference between the two in this regard.

    I did, however, misstate the situation. “wp-config.php” is sometimescalled twice on page load, but not as often as I had thought. For example, the plugin screen in Admin sometimes loads that file twice.

  5. Robert
    #525 | Posted June 8, 2009 at 3:53 pm

    Stephen,

    The admin panel always feels slow to me. Especially the time after entering the URL and getting to the login screen.
    It’s the only time I notice a slowdown.
    The website itself is fast, but it has no content yet, other than the initial WP post.

  6. #526 | Posted June 8, 2009 at 5:08 pm

    Hi Stephen,

    I tried setting $vmb_core_only to true, but no change.

    I did have a thought that may be a possibility. I configure my WP installs so that the WP code is in a subdir of the main htdocs folder, so (ex: htdocs/wordpress/) and then I have an index.php at the top level call wordpress//wp-blog-header.php. Pretty standard WP stuff (http://codex.wordpress.org/Giving_WordPress_Its_Own_Dir...)

    One other thing that I’ve noticed with VMB diags turned on. For just 1 page load, I sometimes see the VMB diags spit out 8 times or so. Could there be some loop occurring?

  7. Mished
    #527 | Posted June 8, 2009 at 5:23 pm

    Was really glad to find your VMB and now trying to get it installed and all.

    But my hosting provider claims that symbolic links cannot be established on their server because of suPHP (which they recently implemented).

    Just need a quick confirm on this because, based on something else they’ve told me that I could confirm myself, I’m not sure I should take their word for it.

  8. #528 | Posted June 15, 2009 at 10:17 am

    KJH — this web site works the same way, with the WordPress files in a subdirectory. (Yes I need to update the docs!) I did that to get rid of the infinite loop caused by the “nerdaphernalia” symlink pointing to its own parent directory. It’s been running from the subdir for a year at least, so no, that’s not the problem.

    As for loading eight times, I have no idea why that would happen. Is there some sort of loop happening in your .htaccess perhaps?

    FYI — how this site runs:

    1) WordPress files in a directory /wp/
    2) WordPress index.php file in both /wp/ and in web root
    3) “nerdaphernalia” symlink points to /wp/

  9. #529 | Posted June 15, 2009 at 10:30 am

    Mished — I have no idea what your host’s setup is. At the least, it’s possible that when the say “can’t” they really mean “won’t”, which for your purposes is the same thing.

  10. #530 | Posted June 15, 2009 at 1:18 pm

    mished, hate to say it but I would be looking for a new host. Aside from that I am just reporting in regard to the comments on speed issues. Really not sure what could be causing this as I have one VMB install linked to a large number of blogs. Some are on their own domain with their own databases, some are sub domains with their own databases and the rest are sub directories using a centralized database. All load times are within 1 second of each other and take at most 3 seconds to load.

  11. #531 | Posted June 22, 2009 at 3:49 pm

    [...] is also Stephen Rider’s Virtual Multiblog which sounded great at the outset, but the instructions proved quite complicated, involving [...]

  12. Anonymous
    #532 | Posted June 25, 2009 at 5:28 am

    First of all thanks for this great plugin. I have wordpress 2.8. I downloaded multiblog_2.6.0 and when I looked at the config file I didnt find a few entries, for example there is nothing corresponding to wordpress 2.8′s variable
    define(‘NONCE_KEY’, ‘put your unique phrase here’);

    Secondly how do I define things like enabling Cache etc which I am able to define in wordpress’s config file as define(ENABLE_CACHE, true);

    Please guide.

  13. #533 | Posted June 25, 2009 at 9:27 am

    NONCE_KEY debuted after the last release of VMB. Go ahead and put it in there.

    RE “ENABLE_CACHE” — you can define **any** constant using $vmb_const in a config file.

  14. #534 | Posted June 26, 2009 at 9:45 am

    Hi all. I’ve just updated to WP 2.8 for testing. I’ve read about multiblog_2.6.0 and I am a bit lost as I don’t see you’ve released a new version. Is that true?
    Can I use 2.5 ok with WP 2.8 or do I need an upgrade?
    Thanks for your good work.

  15. #535 | Posted June 26, 2009 at 11:24 am

    The latest release of VMB works fine with WP 2.8.

    Further info in the FAQ — in short, VMB is so “low level” that it’s pretty future proof.

  16. #536 | Posted June 26, 2009 at 12:17 pm

    Thanks Stephen, I assumme that means “latest” is still 2.5.

  17. Chris
    #537 | Posted June 27, 2009 at 3:08 am

    Sorry if this is a stupid question, or has been answered. Is this http://justintadlock.com/archives/2008/09/20/installing... combinable with VMB? Justin suggests using this
    define(‘CUSTOM_USER_TABLE’, ‘wp_users’);
    define(‘CUSTOM_USER_META_TABLE’, ‘wp_usermeta’);
    in wp-config for a second blog to share users across two (or presumably more) blogs which have the same database. All the other tables in the database will have a per-blog prefix, but the users & usermeta tables will be shared.

  18. #538 | Posted June 27, 2009 at 2:08 pm

    Chris –

    Yes, that will work — such as it is. That sharing system is basically incomplete, though. You share the users, but users from one blog don’t have any rights on the second blog. Further work is needed for it to really work. Look on Google for a WP plugin called “wp-orphanage” — that may help things along quite a bit.

  19. #539 | Posted July 5, 2009 at 2:15 am

    [...] flexible, but it seemed more complicated than necessary, adding a lot of configuration and code (Virtual-Multiblog). This could work, and I think I could have kept hacking away to get something more flexible, but I [...]

  20. #540 | Posted July 6, 2009 at 6:22 pm

    While I think this is great, I think I may have figured out the ultimate solution to this problem, using only one symlink and some htaccess rewrite rules. Check it out here: http://theoephraim.com/?p=7

Pages: « 122 23 24 25 26 [27] 28 29 30 31 3235 » Show All

Post a Comment

Your email is never shared.

Subscribe without commenting