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: « 115 16 [17] 18 1920 » Show All

  1. #321 | Posted October 8, 2008 at 4:41 pm

    NewUser — Good question.

    I have been using auto plugin update just fine for quite a while. Really, all that happens is the plugin files are deleted and replaced with the new version; so as I understand it, running the auto-update is not any different than if you were to upload the new plugin via F T P.

    Note: There are “hooks” that plugin authors can use to run code when their plugin is activated or deactivated, which some may use to include update functions; but these do NOT run during auto update — so even there it’s really no different than using F T P. It’s just more convenient. :)

    [Update: WordPress is doing weird things to the term F T P -- namely, turning it into a link. That's why I added the spaces between the letters....]

  2. jk
    #322 | Posted October 8, 2008 at 7:58 pm

    i’m missing something in the readme file it says for step 4
    - Move the multiblog-support folder from multiblog/plugin/ to you plugins folder (probably wp-content/plugins/).

    im not seeing either the multiblog/plugin or multiblog-support folders in the zip file

  3. #323 | Posted October 8, 2008 at 10:00 pm

    JK — I need to correct that! The plugin no longer exists — it was rolled into the base system files. You can ignore that step.

  4. #324 | Posted October 11, 2008 at 1:19 pm

    My warm congratulations for this excellent code! Elegant, easy and efficient!

    I have only two remarks for the the installation instructions (multiblog-readme.htm) and a question:

    1. Usual installation of WP is not needed. If I am not wrong, only the WP files should be uploaded.

    2. I spent some time searching and thinking, till I read here that the multiblog-support folder from multiblog/plugin/ does not exist any more. This should be deleted from the instructions.

    I have copied WP in a subdirectory and created some symbolic links in the root dir that point to it; they work perfectly for Virtual MultiBlog. Then I pointed some subdomains to the directory where WP is in, and they do not open the 5min installation, the root directory opens instead. However, subdomain pointing works for folders that do not contain WP files, so I assume, that WP does not accept it. Do you have any idea about this?

    Thank you again and keep on doing the good work!

    Alexandros

  5. NewUser
    #325 | Posted October 12, 2008 at 8:03 am

    Stephen: ok, but when I update plugin, it’s deactivated only on one blog… So on other blogs hooks won’t run, is that right? Or am I missing something?

  6. #326 | Posted October 12, 2008 at 7:44 pm

    NewUser — I repeat: during auto update, the deactivate/reactivate hooks do NOT run. That is standard WordPress behavior. They did it that way because many plugins are programmed to delete their own preferences on deactivate.

    Thus, with or without Virtual Multiblog, those hooks do not run during auto update.

  7. tom
    #327 | Posted October 17, 2008 at 10:57 am

    Hi there,

    I’m wondering if you can provide any insight into a problem I’ve encountered–

    I’ve set up Virtual Multiblog to great success on my site. I set up three blogs using VM and everything is working fine (two are in subdirectories, one is the root install). However, as I add subsequent blogs (all in root subdirectories), they install fine and I’m able to go into wp-admin and admin the blog as usual, but when I visit the blog, I only get a blank page. And the original three blogs are all functioning fine. I’ve followed the same, precise install process for all of them, but I still can’t get additional blogs to display. The DB also seems fine (the necessary tables exist for all blogs, including expected fields/values–even for those blogs that aren’t displaying.)

    The only issue I could find on my own was that PHP memory allocation may be set too low, but I checked php.ini and it’s set at 90M which should be fine.

    Any ideas?

  8. TOM
    #328 | Posted October 17, 2008 at 12:18 pm

    Problem solved! It seemed for some reason, with the later blogs I created, the theme didn’t “take”. By changing themes, and then reactivating the original theme, everything was again displayed. Odd! I don’t know why this didn’t happen when creating the first blogs… All’s well that ends well.

  9. #329 | Posted October 17, 2008 at 2:54 pm

    I have been trying to install this great program without success. After I follow all of the steps I get a cannot connect to database error. The WP installed worked until I added the VMB program.

  10. #330 | Posted October 17, 2008 at 3:09 pm

    Paul — That error says that there’s something wrong with the config. Try putting your database info into the autoconfig file and see what happens. (Also, you removed the “-sample” from the filename, right?)

    Heh. I had that exact issue installing the latest development version the other night… Didn’t update my config files.

  11. #331 | Posted October 17, 2008 at 3:13 pm

    Alexandros –

    It may be a problem with _how_ you are pointing the subdomains. Redirects will not work — they have to be set up at the server level. The next release of VMB will have a workaround for that (experimental though!).

  12. #332 | Posted October 18, 2008 at 2:52 pm

    Is there a way to import blogs into this system?
    Also if I am hosting blogs 1-14 all with different URI how does this effect stats?
    Thanks

  13. #333 | Posted October 18, 2008 at 3:09 pm

    Also, is there a way to only show the “multiblog” link in one of the admin panels?

  14. #334 | Posted October 18, 2008 at 3:38 pm

    Paul — To “import” an existing WordPress blog, just create a custom config file for that vuser, and put the existing blog’s database info and table-prefix in the config file.

    Stats? Depends on how your collecting stats, I guess…

    The next version of VMB will allow you to turn off the admin stuff. Hopefully I’ll be releasing it soon — I’m polishing up backward compatibility in the wake of some changes to the way config files work.

  15. Ximena Eduarda
    #335 | Posted October 19, 2008 at 5:24 pm

    I used VIrtual Blog as local host and worked just fine, as I am doing this for someone else I need to upload without it, how do I go back to original. Sorry if question is dumb, in fact I am so new to all this that I can ask the most incredible things to those that know about it.

  16. johnny_n
    #336 | Posted October 28, 2008 at 11:54 am

    Hi Stephen — anxious to try this, what a fantastic concept. I have one quick question:

    How easy is it to change a virtual blog from a subdomain to a real domain once it’s been created?

    In other words, I want to test using a subdomain (domain2.domain1.com), but when the site is ready, I want to move it to domain2.com, with the subdomain removed completely.

    If I understand things correctly, wouldn’t I just change the appropriate $VUSERS line to reflect the change within Virtual Multiblog?

    Then, on the server side, I would create a new symbolic link that pointed domain2.com to domain1.com.

    Is it this simple?

  17. #337 | Posted October 28, 2008 at 12:35 pm

    Ximena — to go from VMB to standard WordPress, simply restore the standard wp-config.php file. You will have to fill in the appropriate info of course (including table-prefix).

    johnny_n — If you are using “easy setup” the system determines your table-prefix based on your domain, so you will have a table-prefix based on the test domain. If you use Advanced setup you can specify the table-prefix, and this is then not a problem. Other than that, your method (plus maybe changing the name of the config file) is correct as far as Virtual Multiblog goes.

    There are, however, issues with changing domains in WordPress — things that have nothing to do with my system. Here’s an article with more info on that: Move your WordPress blog to a new domain in 10 steps

  18. johnny_n
    #338 | Posted October 28, 2008 at 1:12 pm

    Thanks very much for your quick response and passing along that link — very good to know indeed. Some of it doesn’t apply since it’s all remaining on a single server, but much of it does.

    I did install using the advanced setup — can’t quite get things working properly yet (whether I go to domain2.domain1.com or domain1.com I get the same blog) but should have it worked out shortly… I did want custom table-prefixes which is why I used the Advanced.

    best–
    john.

  19. johnny_n
    #339 | Posted October 29, 2008 at 1:51 pm

    I’ve read the last several pages of comments, I’ve read the readme probably 15 times, I’ve read the FAQ. Still the same problem as above (whether I go to domain2.domain1.com or domain1.com I get the same blog — domain1.com).

    My host set up a symlink for me and I can even see it works in my FTP software. The install for domain1 went fine, with the custom table prefixes used.

    The only clue I have is when I go to domain2.domain1.com/wp-admin/, I get this:

    http://domain1.com/wp-login.php?redirect_to=http%3A%2F%...

    There is nothing in my .htaccess file except for a password protect and custom permalink redirect from WP (doesn’t matter whether that is there or not, same result, I’ve tried both ways).

    Does this mean there is a hidden redirect somewhere that I can’t find, overwriting the symlink?

    I’m really at a loss…

    One other thing — my db isn’t @ localhost. Would this have anything to do with it?

    john.

  20. #340 | Posted October 29, 2008 at 4:59 pm

    Generally, if it’s defaulting to the first $vuser[], that means it can’t figure out which one to use — the system uses the first on the list as the fallback. You can test this by reversing the order of your $vusers[] list — probably both addresses will be blog #2 then.

    Other things to try:

    WordPress rewrites .htaccess, so that still could be the problem. When you remove the WP stuff, save it, then lock the file so it can’t be written by anyone.

    In the config for the second blog, set WP_HOME and WP_SITEURL.

Pages: « 115 16 [17] 18 1920 » Show All

Post a Comment

Your email is never published nor shared.

Subscribe without commenting