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: « 123 24 25 26 27 [28] 29 30 31 32 3335 » Show All

  1. dndco
    #541 | Posted July 6, 2009 at 6:35 pm

    Theo, I hate to burst your bubble but the multiblog solution is actually less complicated than what you have come up with. It is truly one code base meaning all the files in one place, period. On a Linux box (especially one using LX Admin) changing the Document Root is a breeze. New blog. I just change one line in one conf file. Done.

    What is needed is activating plugins across all the blogs ;)

  2. #542 | Posted July 22, 2009 at 11:27 pm

    Virtual Multiblog version 2.6.1 is up. The primary new feature in 2.6 is auto-plugins. You can specify plugins to be automatically activated across all (or just some) blogs.

  3. #543 | Posted July 23, 2009 at 3:00 pm

    [...] Virtual Multiblog [...]

  4. #544 | Posted July 24, 2009 at 12:12 am

    [...] Virtual Multiblog [...]

  5. #545 | Posted July 24, 2009 at 6:46 pm

    [...] Continued here:  Virtual Multiblog for WordPress – Nerdaphernalia [...]

  6. #546 | Posted August 7, 2009 at 6:25 pm

    Hey Stephen,

    I’ve been using your multiblog script for a while, ever since version 2.5 I believe. However, I’ve recently wanted to use my domain root (redbluemagenta.com) as a WP blog. I have my wp files stored in a different directory (public_html/wp) and have successfully spawned a few other blogs from that directory (blog.redbluemagenta.com, themetest.redbluemagenta.com, redbluemagenta.com/site). However, I’ve tried following the directions from the main WordPress site for making the main doc root a blog as well (http://codex.wordpress.org/Giving_WordPress_Its_Own_Dir...) but it doesn’t seem to work; it repeatedly reloads the page, and Firefox eventually tells me that it ran into an error. I’ve copied my custom .htaccess file into public_html:

    RewriteEngine On
    RewriteCond %{REQUEST_URI} (/blog|/themetest|/site|/wp)?/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . %1/index.php [L]

    SecFilterEngine Off
    SecFilterScanPOST Off

    … and I’ve also tried redoing the entire .htaccess file in order to mirror what WordPress usually writes in the .htaccess file when it actually has write permissions for it. No go. I’ve read the majority of the posts here and none of the suggestions seem to work. What do you suggest I do from here? Is it possible for you to post your .htaccess file as well?

  7. Chris
    #547 | Posted August 8, 2009 at 1:40 am

    Has anyone tried VMB with the new plugin W3 Total Cache? It seems to work quite differently from Super Cache and Hyper Cache.

  8. Philip
    #548 | Posted August 8, 2009 at 11:33 am

    I’m just trying to install your plugin and wondered if it modifies the database structure and if comments from different domains are in the same table or different ones? I’m looking for a future proof solution which also allows me to return to multiple WordPress installations in case that the plugin won’t be supported any more, etc.

  9. Laurence
    #549 | Posted August 9, 2009 at 4:29 am

    hi Stephen

    Many thanks for this system, it is simple and effective. I tried to grapple with WPMU and multiple domains but it was a nightmare and didn’t feel ‘clean’ in the slightest.

    A couple of questions:

    a) one of my sites is a little slow on the first load, i.e. when i go to it cold, there seem to be a couple of seconds before it begins to load. Subsequent loads are very fast, just as expected. I have no idea whether this is a VMB issue, but I wonder if you have any thoughts. I have one other (non-VMB) WP blog on the same server and it loads very quickly from the off.

    b) can you set up a forum for VMB support? :) I see you suggested it last year but I can’t find it on the site. It’s a bit frustrating to look through these comments to find answers – a simple little forum would make life a lot easier!

    Cheers :)
    -Laurence

  10. Laurence
    #550 | Posted August 9, 2009 at 5:43 am

    Another question, Stephen:

    Is is possible to create a VMB installation on a testing directory before moving the domain to point to it? I ask because I would like to move an existing blog to VMB without any downtime. I made a symlink at testserver.com/vmb then recreated the blog there – all plugins etc, so basically a carbon copy.

    When I pointed the main domain (realsite.com) to that place on the server, I get the installation screen. I changed the names of the tables in the database to match realsite.com, but that only worked for the homepage and other pages either didn’t work or took me to the installation page (tbh I didn’t expect that to work but I thought it would be worth a bash).

    Rather than setting up a whole new blog on realsite.com, which would involve downtime (and potential security problems – what if someone creates the blog in the few seconds that the installation screen appears?), is it possible to create the VMB blog elsewhere on the server, then change some settings so that a different domain can point to it?

    Any help much appreciated :)

  11. #551 | Posted August 10, 2009 at 11:27 pm

    merc248 — This site works very similarly to what you describe. First off though, you only need to monkey with .htaccess for blogs in different directories. Blogs in subdomains work just fine. Thus:

    RewriteCond %{REQUEST_URI} (/site)?/

    Regarding moving the WP files, that works well too, with one small change: Instead of moving the index.php file out of the WP directory, you want to copy it. That is, you will have two WP index.php files: one in the /wp/ directory and one at the blog root. Open up the one at the blog root and change the path per normal WP instructions.

  12. #552 | Posted August 10, 2009 at 11:30 pm

    Philip — it’s pretty future proof. It doesn’t modify the database structure. It allows you to specify different database login info, OR a different “table prefix” for each blog — both of which are pretty stock standard WordPress things. To move off the system in the future you could put separate copies of WP in the appropriate places and run them off of standard wp-config.php files (setting the appropriate login info and prefixes of course.)

  13. #553 | Posted August 10, 2009 at 11:34 pm

    Lawrence:

    a) I don’t know why VMB might cause this. Maybe a caching thing?

    b) I haven’t spent a lot of time on VMB because there doesn’t seem to be a lot of interest. Frankly — off the top of my head, I believe VMB has received a single donation in the entirely of 2009. With regards to searching comments, I would suggest hitting “show all” and then doing a text search on the resuiting (looooong!) page.

  14. #554 | Posted August 10, 2009 at 11:39 pm

    Try setting something like:

    $vmb_const['WP_SITEURL'] = ‘http://testserver.com’;
    $vmb_const['WP_HOME'] = ‘http://testserver.com’;

    …in your test-server’s config file.

    Be aware that some parts of WP, including file uploads, set hard URLs in the database, which could cause a problem moving sites.

    [UPDATE: Correction to suggested WP_HOME ]

  15. #555 | Posted August 10, 2009 at 11:43 pm

    Stephen,

    One other question: when we follow the directions on the WP page for moving the WP install away from the root directory, do we edit the index.php file so that it points to the _real_ WP installation directory, or can we use whatever symlink for whatever blog we want to move to the root?

    For example, say I have two blogs, foo and bar. ‘foo’ is the WP installation, and ‘bar’ is a symlink to ‘foo’. If I wanted to “move” the ‘bar’ blog to the root directory, would I edit the index.php file so that it’s pointing to ./bar/wp-blog-header.php, or will I have to point to ./foo/wp-blog-header.php?

  16. Laurence
    #556 | Posted August 11, 2009 at 3:01 am

    Stephen

    Thanks for your answers, I will try it out. I’m surprised there isn’t more interest in VMB. I found WPMU just didn’t work (I didn’t see an ‘add blog’ option) and it appeared that configuring it to work for completely different domains requires code hacking and whatnot. Not very elegant, especially compared with VMB.

  17. #557 | Posted August 11, 2009 at 2:53 pm

    [...] Virtual Multiblog [...]

  18. #558 | Posted August 11, 2009 at 3:23 pm

    Here is what I have on this site:

    1. WordPress files are in /wp/ directory

    2. “nerdaphernalia” symlink pointing to /wp/

    3. Copy of WP index.php at site root, containing (among other things) the line:
    require('./wp/wp-blog-header.php');

    No, there is not a blog at /wp/. I can’t just point the root blog to WP files in a /nerdaphernalia/ directory, because if I do that I won’t have any way to access the admin for the root blog. Both blogs would have admin at /nerdaphernalia/wp-admin/ which doesn’t work!

  19. #559 | Posted August 11, 2009 at 3:24 pm

    Great script. I love it and would like to be able to implement it with all my sites, but I can’t figure out how to do one thing: I want the ability to give some sites their OWN wp-content folder while totally sharing the same codebase (and wp-content folder) for the others. So, is it possible to do this? Thanks.

  20. #560 | Posted August 11, 2009 at 5:29 pm

    See “Moving wp-content” on this page: http://codex.wordpress.org/Editing_wp-config.php

Pages: « 123 24 25 26 27 [28] 29 30 31 32 3335 » Show All

Post a Comment

Your email is never shared.

Subscribe without commenting