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.5

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.

383 Comments

Pages: « 112 13 [14] 15 1620 » Show All

  1. #261 | Posted August 4, 2008 at 8:09 pm

    Thanks for the reply. Another quick question, I’m trying to use VUSER in an if/then statement and I keep getting errors. I’m guessing this is a PHP issue:

    Neither work…

    <?php if ($vuser(’domain.com’)) { wp_list_categories(’include=1,3,4,5,6,7&title_li=Test Categories’) } ?>

    or

    <?php if ($vuser = ‘domain.com’) { wp_list_categories(’include=1,3,4,5,6,7&title_li=Test Categories’) } ?>

    what is correct use of VUSER?

    Thanks!

  2. #262 | Posted August 5, 2008 at 12:05 am

    Matthew — VUSER is neither a function nor a variable. It is a constant. Try:

    if (VUSER == 'domain.com')

    (Note the double equal sign ‘==’)

  3. #263 | Posted August 11, 2008 at 3:12 pm

    HI am having problems with logging in as my password won;t reset. I understand this is due to a bug in 2.5.1 - is is possible to upgrade to 2.6?

    If not doesn anyone know how I can login and rest my password?

  4. #264 | Posted August 19, 2008 at 10:24 am

    I’m having trouble getting this working due to 403 forbidden issues. I have a directory ‘wordpress’ in /var/httpd/vhosts which MB is set up in, and which I’m symlinking to.

    What works:
    example.com/blog/ example.com/foo/ (since I can override with ‘Options -SymLinksIfOwnerMatch +FollowSymLinks

    What doesn’t:
    example.com domain.org (ie domains with the blog installed in the root)

    For these I have added (in /etc/httpd/conf/httpd.conf):

    <Directory /var/www/vhosts/wordpress>
    Options -SymLinksIfOwnerMatch +FollowSymLinks
    </Directory>
    

    and also tried

    <Directory /var/www/vhosts/example.com>
    Options -SymLinksIfOwnerMatch +FollowSymLinks
    </Directory>
    

    but I’m still getting “Symbolic link not allowed: /var/www/vhosts/example.com” errors, with a 403 Forbidden returned when I try to access the blog via http://example.com. Now I may have messed up the Apache directive or something similar, but some searching of the web has revealed nothing.

    Any help? Thanks in advance :-)

  5. #265 | Posted August 19, 2008 at 9:45 pm

    Robert — Am I understanding correctly that you’re doing two blogs in the root directory of two different domains?

    If so, you don’t need symlinks. Give both domains the same document root and you’re good to go.

  6. #266 | Posted August 19, 2008 at 9:47 pm

    Gerry — Not that this has anything to do with this system, but your best bet is to find some way to access the database directly (PHPadmin perhaps) and delete the password from that user.

    Log back in (no password) and set the password to whatever you want.

  7. #267 | Posted August 19, 2008 at 11:02 pm

    Still *love* the plugin …

    I am really struggling with Permalink issues … I don’t know if it is Multiblog, but I find that I have to “reset” the permalinks almost everyday. They work for a while, then break. Real drag for RSS feeds, not to mention all navigability.

    I have about five blogs running on Multiblog … ONLY 1 has custom links, the rest use the default. I’ve read the Permalinks section in the Readme, and tried its recommendations to no avail ….

    thoughts?

  8. #268 | Posted August 19, 2008 at 11:20 pm

    dhkeller —

    WordPress is resetting the rewrites. Set permissions on .htaccess — turn off “write” permission and then WordPress can’t change it.

    New version of VMB may fix this — I have a test version (very alpha) that alters the WP rewrites….

  9. #269 | Posted August 20, 2008 at 9:57 am

    Stephen:

    Ah, clever. Should have thought of that but I didn’t; my mind was fixated on symlinks.

    I’m actually going to be using it in three different ways - domain, subdomain and directory. The first two should work fine by pointing the DocumentRoot at the root of MB, and I’ve already tested subdirectories.

    Fantastic. If (once) I get it working, I’ll send a donation your way.

  10. #270 | Posted August 23, 2008 at 12:52 pm

    I have installed your multi blog contribution. It’s great! I’m using it at http://www.savemoney.com/tblog right now. I’m having a little trouble though. The http://www.savemoney.com/tblog throws up a multiblog error.

    Warning: stristr() [function.stristr]: Empty delimiter. in …

    The directories http://www.savemoney.com/tblog/main and http://www.savemoney.com/tblog/realestate both work correctly. Can you help me figure this out? My mb-users file looks like:

    $vusers[] = ‘main’;
    $vusers[] = ‘realestate’;
    $mydomain = ’savemoney.com’;

  11. dndco
    #271 | Posted August 25, 2008 at 12:27 pm

    Initially I went the symlink route and ended up with the 403 error. Then I came here and read that in a similar situation to mine i.e. two domains you are to share the document root instead. So i tried that and I just get a white page. With this code underneath;

    
    < ?php
    /**
    * Front to the WordPress application. This file doesn't do anything, but loads
    * wp-blog-header.php which does and tells WordPress to load the theme.
    *
    * @package WordPress
    */
    
    /**
    * Tells WordPress to load the WordPress theme and output it.
    *
    * @var bool
    */
    define('WP_USE_THEMES', true);
    
    /** Loads the WordPress Environment and Template */
    require('./wp-blog-header.php');
    ? >
    

    It appears as though PHP is not running but PHP and WP are working on the other domain that is in the same doc root.

    I tried the simeple and advanced with vuser setup both have the same result.

    Any ideas?

  12. #272 | Posted August 25, 2008 at 12:51 pm

    dndco — The code didn’t go through. email it to me.

  13. #273 | Posted August 25, 2008 at 7:12 pm

    dndco

    The space in the first and last lines is probably preventing the PHP from running. Other than that, you’re looking at the standard WordPress index.php

  14. dndco
    #274 | Posted August 26, 2008 at 1:27 am

    I put the space in the code because I wasn’t sure if it would be stripped out or not.

    Yes, that is the WP index.php but the server is not recognizing the PHP on the second domain which is pointing at the new shared root. The primary domain works fine. I had my host look at it an now they have basically gone backwards and made it into an alias. One domain is just pointing to the other.

    What can I have them try next? Has anyone gotten a two domain version to work? Was Robert above successful? I would LOVE to get this working!

  15. #275 | Posted August 26, 2008 at 7:17 am

    I’m wondering if VMB still has issues with WP-Cache or Super Cache? If so, do you have an idea of what is wrong? If you point me in the right direction, perhaps I can help.

  16. #276 | Posted August 26, 2008 at 7:46 am

    dndco — I have no idea why one domain would run the PHP and another would not. Probably a server setup issue. YES, plenty of people (including myself) have set this up with multiple domains pointing to a common root.

    Lan — The issue is that both blogs share a common .htaccess file. The caching plugins both change the .htaccess specifically for a particular blog, and then it doesn’t work for the other blogs. It could probably be made to work with a sufficiently clever modification of the stock WP-SuperCache rewrites, but I haven’t had time to try it much.

    If you’re looking at getting it going, you might also see about making it work with a plugin called batcache. That might be easier than the others.

  17. jz
    #277 | Posted August 26, 2008 at 12:35 pm

    Stephen:
    You asked if the information is worth 1 dollar. Yes,it is worth even more So! once I figure this out I am going to rewrite the installation directions and give you part of the proceeds from the small amount I charge. I will be better than the hours it takes to tey an figure this out and I am a programmer.

    Your answers will be grealty appreciated and anyone who wants to contribute information for different setups i.e. use of directories with sym links, subdomains or domains add to this message. Thanks jz

    I set up Wordpress in a subdomain called
    news.mycarfs.com

    I also created subdomains called
    cfs.mycarfs.com
    maxima.mycarfs.com
    pwtc.mycarfs.com

    With your web browser, go to each blog and set things up as normal through WordPress. What does this mean ?

    How do I setup each subdomain for wordpress?
    How do I point the subdomain back to news.mycarfs.com

    Do I use mb_config.php if I want to use prefixes in 1 database instead of mb_auto_cinfig.php?

    When I want to go to the different blogs do I just type in the sub-domain name of the blog?

    You’re done! Told you it was easy! NO IT IS NOT THAT EASY

  18. #278 | Posted August 26, 2008 at 3:01 pm

    Lost noob needing advice. Hi — I need to have four separate blogs operating on our presbytery website (executive, associate executive, Rwanda partnership, and Disaster Assistance Teams). Virutal multiblog would be ideal for our purposes, but I am lost in the references to symlinks. If each of these blogs will be a subdomain, it looks to me from the FAQ like I don’t need symlinks, but I am not clear what I need to do after I follow the first six steps in easy set-up, which I’ve done. Do I then modify the mb-users file, or what? thanks for your help, Erin Cox-Holmes

  19. #279 | Posted August 26, 2008 at 3:30 pm

    JZ —

    Am I understanding correctly that you intend to write instructions for this system and directly charge people for them? Good luck with that.

    Writing clearly, especially on technical issues, is not an easy task. Judging from your comment, your writing needs work. Your reading comprehension is also in need of practice. To whit:

    With your web browser, go to each blog and set things up as normal through WordPress. What does this mean?

    It means open a web browser (e.g. Firefox) and go to news.mycarfs.com. WordPress will run a setup routine. Then do the same for your other subdomains.

    But in your case, you clearly don’t have the subdomains pointed to the same document root as news.mycarfs.com, because when I visit those addresses I get a HostMonster parking page. If they were pointed to the same place, I would get the WordPress setup page.

    Also, in answer to your question regarding config files, I suggest you reread the readme, especially the first sentence of Easy Setup, and around step 4 of Easy Setup.

  20. #280 | Posted August 26, 2008 at 3:41 pm

    Erin –

    1) All of your subdomains should be pointed to the directory in which you’ve installed WordPress. That is, the “document root” of each subdomain should all be the same folder, and that folder should have the WordPress files directly in it. You do not need symlinks.

    2) The “multiblog” folder should be inside the “wp-content” folder. Take the wp-config.php file out of the multiblog folder and move it up to the root folder. (If you already have a wp-config.php there, rename it wp-config-old.php.)

    3) In /wp-content/multiblog/config/, set up your mb-autoconfig.php.

    That should be it. Each address should give you the WordPress setup screen.

Pages: « 112 13 [14] 15 1620 » Show All

Post a Comment

Your email is never published nor shared.

Subscribe without commenting