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.

116 Comments

  1. #1 | Posted November 19, 2006 at 1:01 pm

    [...] The even better news is that changes to WP2.0 makes it even easier to apply, and that a guy named Stephen Rider has taken the time to describe the setup, package it neatly and include a little readme file with instructions that are better than what I originally wrote so I’m not going to improve on it. [...]

  2. #2 | Posted December 21, 2006 at 1:31 am

    [...] After a few unsuccessful attempts to build pages and get Wordpress to put content on those pages (posts, links, etc.), I realized that what I really needed was a mini-CMS (content management system).  I did some digging on the Wordpress site and found two good links that pointed me in the right direction (http://www.mertner.com/allan/archives/2004/choosing-an-engine/) and more importantly, (http://www.striderweb.com/nerdaphernalia/2006/10/hello-again-world/).  By building Unix soft links to the main Wordpress install directory, and making a few minor changes, you can host multiple blogs, which is what I was really looking for. [...]

  3. Chris Gibbs
    #3 | Posted January 25, 2007 at 4:22 pm

    Wow! I have a project I’ve been dreading for a long time because I couldn’t find anything like this. Thank you for sharing your experience!

  4. #4 | Posted January 25, 2007 at 8:07 pm

    Nice to see people are finding it useful.

    When I first found Allan’s page, I was surprised the method wasn’t being talked about more than it is….

    I was actually very pleased to see a new feature in the just-released WordPress 2.1 that is somewhat related to this: the ability to make any arbitrary page your home page, and put the blog somewhere else. With that in place I should now be able to run my entire site off of WordPress :)

  5. #5 | Posted March 18, 2007 at 12:00 pm

    Please forgive my utter ignorance. What I want to do is have several different areas of content, with “blog a” on the index page, “blog b” and “blog c” on two separate pages.

    What I want, essentially, is each broad category of posts on its own page, with different levels of access.

    Does this marvelous code make that possible?

  6. #6 | Posted March 18, 2007 at 10:56 pm

    Pastor Ed — That’s exactly what this will do! :)

    Basically, install Wordpress in the root directory of your website. Then make symbolic links pointing to the root directory and call them “blogb” and “blogc”. Follow the directions on this page, and you can have three different blogs with the one install, at yoursite.com, yoursite.com/blog-b, and yoursite.com/blog-c.

    NOTE: You may have to have your web host set up the symbolic links for you; and not all web hosts can do this — I believe if your site is hosted on Windows this will not work, but if you’re hosted on Unix, Linux, or Mac, you should be good to go. (Not all operating systems allow Symbolic Links).

    Good luck!

  7. #7 | Posted April 11, 2007 at 3:03 pm

    Thank you for this great plugin/hack, very precise and cool!
    I am using it and I feel very happy I came across this page.

    It must have been a lot easier to understand to many here probably because this all seems streamline to the more advance users.

    But I was new to this thing but after a couple of minutes of google.ing and reading on symlinks I finally got how this is supposed to be done.

    Some links I found useful:
    How to create symlinks using .php on shared hosting..
    http://www.ideasfornet.com/how_to_create_symbolic_links...

    The “permission denied”??? error
    Setting permission for the root folder, bc php will need it to create the symlink
    http://blog.diefirma.de/2006-03-20/creating-symlinks-on...

    One last thing I wanted to state in other words..(which is quite obvious if you know how it works, yet the instructions had me confused for good half hour)

    Symlink Addresses
    The symlink will need to point “default single wordpress installation folder” to the “your virtual secondary blog folder”..

    or even more simple:

    using the instructions’ example scheme..

    [The code disappeared here, but is readable in this comment -- ed]

    Where the bob folder exists, containing the wordpress installation
    and where there is no existing joe folder.
    it will be created after this script runs successfully.
    Bob will contain the original default blog installation, plugins, & themes..
    userid ..should be replaced with your own corresponding server path id

  8. #8 | Posted April 11, 2007 at 3:09 pm

    my code in the previous comment has loaded invisible
    (right after “using the instructions’ example scheme..”)

    .. maybe that could be fixed

    =)

  9. #9 | Posted April 11, 2007 at 4:43 pm

    Since this blog is still active I thought I’d let everyone know about this:
    http://mu.wordpress.org/

    Don’t know if you have seen that or not but I found it much easier to work with.

  10. #10 | Posted April 11, 2007 at 10:35 pm

    MO… The missing code did not make it to the database — all I see is an empty set of <code> tags.

    To rephrase your example a bit:

    The ‘bob’ folder exists and contains the WordPress installation. You are going to create a symbolic link called ‘joe’ that is a second representation of the ‘bob’ folder. In effect they will be two identical folders, but in reality it is a folder called ‘bob’ and a symbolic link called ‘joe’.

    CHRIS –

    I have heard of WordPress MU, but haven’t checked it out. One thing I like about my methodology is that you don’t have to worry about plugins not being compatible, whereas not all plugins are compatible with WordPress MU (or so I hear….)

    I’m sure most people will probably go with the standardized method, but it’s always nice to have alternatives if there is a problem with one method, and this way _does_ work quite well. :)

  11. #11 | Posted April 11, 2007 at 10:43 pm

    Stephen, I agree. I have found most plugins incompatible with Wordpress MU (as well as templates!). So it is good that we have options.

  12. #12 | Posted April 15, 2007 at 1:50 pm

    Stephen, this looks like just what I need and would appreciate the answer to two questions (I know, I could experiment and see but…)

    - is it necessary for the directory with the real WP files to be one of the blogs or can all the blogs be virtual?
    - can existing blogs be converted to virtual blogs?

    Thanks,
    Bill

  13. #13 | Posted April 15, 2007 at 11:20 pm

    Bill –

    RE: the first question, the “real” directory will work as a blog, because the blog software is there. If somebody goes to that directory with their browser, WordPress will be there. (Though I suppose you could activate an “all blank pages” theme or somesuch).

    As for converting existing blogs — I don’t see why not. Beyond the software itself, a WordPress blog comprises the software, a theme, and the data in the database; so you should be able to copy the theme over and delete (or rename) the existing blog folder and replace it with a symbolic link.

  14. #14 | Posted April 16, 2007 at 5:32 pm

    Thanks!

  15. #15 | Posted April 16, 2007 at 7:40 pm

    I guess I could use some .htaccess magic to block direct access to the directory holding the actual WP code, since I don’t want to use it directly.

  16. #16 | Posted April 16, 2007 at 10:01 pm

    Be careful with .htaccess, as it will affect all the blogs (since they’re all the same directory).

    Out of curiosity, why don’t you just make one of the blogs the “real” directory? What is the point of making all of them virtual?

  17. #17 | Posted April 17, 2007 at 8:10 pm

    Not sure I have a good answer for you, just thought it would be best this way, but no big deal if not except that all the blogs involved already exist.

    I am getting an odd error: Notice: Undefined variable: mydomain in /users/home/blazar/web/current_public/wp-core/wp-content/multiblog/mb-functions.php on line 20.

    The readme does not explicitly mention setting this variable in wp-config.php and of course I was not observant enough to notice. However, I saw the error message when I loaded install.php the first time and went back and corrected my error, yet the error message is still there after running the through the install process.

    Any idea on why or how to remove it?

  18. #18 | Posted April 17, 2007 at 8:15 pm

    Also, I’m not too sure if this is the right instruction:

    Make the bob/ directory and put the Wordpress files in it. Place the “multiblog” folder in the wp-content/ directory. In the site’s root directory, create a symbolic link to this folder, and call it “joe”.

    Why is the symlink to the multiblog folder, since if there is more than one virtual blog the symlinks will all point to the same folder? IAC, I am getting a 403 forbidden error when I open http://example.com/virtual1.

    Thanks,
    Bill

  19. #19 | Posted April 17, 2007 at 9:57 pm

    err… no. The symlink should point to /bob/ not /bob/wp-content/multiblog/

  20. #20 | Posted April 17, 2007 at 10:30 pm

    Thanks, that did the trick for #16. Any ideas on #15?

  21. #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!

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

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

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

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

  24. #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.

  25. #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.

  26. #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)

  27. #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... [...]

  28. #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?

  29. #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!

  30. #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.

  31. #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!

  32. #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.

  33. 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!

  34. #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)

  35. #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... :) ]

  36. #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.

  37. #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! :)

  38. #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.

  39. #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.

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

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

  41. #41 | Posted July 12, 2007 at 6:44 am

    [...] I don’t know how to tinker with .htaccess so I just copied the suggested contents from Stephen Rider’s multiblog file and it worked! I am so thankful that my blog is back [...]

  42. #42 | Posted July 12, 2007 at 11:40 pm

    Hi,
    Thanks for visiting my blog. =)

    I made a follow up question with a problem in my blog. Although I think I have the solution, I still need your advice since my solution was just a guess. Thanks.

    Allen

  43. #43 | Posted July 13, 2007 at 11:26 pm

    Hey there, I have noticed a weird problem in my blog. Once in a while, the blog permalinks are not working correctly (redirecting to the other blog thus a dead link). I have to reset the permalink structure just to make it work again. Have you encountered this error?

    Thanks.

    Allen

  44. #44 | Posted July 14, 2007 at 10:18 am

    As stated in the readme, you’re replacing the contents of the .htaccess with something like this:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/(bob|joe)/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /%1/index.php [L]
    </IfModule>
    

    The important bit is that you do NOT want to allow WordPress to overwrite this. Try changing the permissions of your .htaccess so that WordPress can NOT write to it.

    As an additional caution, I would put this replacement redirect _before_ the #WordPress markers, not within them. That way (theoretically) if WordPress does write to the file down the road, the new redirect will fire before the default WordPress one.

  45. #45 | Posted July 14, 2007 at 10:39 am

    Yes I did do that. But I guess I forgot to CHMOD .htaccess… All seems fixed now. Thank you once again for your multiblog idea. ^_^

  46. Dgold
    #46 | Posted July 22, 2007 at 3:36 pm

    This is amazing Stephen. I have been reading (and getting headaches) about every multi-blog option including MU. This was the only one that made sense to me, and actually worked when I tried it. I set up 4 new blogs tonight on 1 install of WP, with your method (and I used mo’s PHP code to make the symlinks because I didn’t know another way to do it - you could improve on the instructions in this area). Before this I already had about 5 WP’s on 5 installs.

    Some of my questions so far:

    1. If I want to move some of my old separate installs under one-roof, should I just Export from the old one, set up a multi-blog “joe” and Import there? Then I would just move the theme from the old separate wp-content, into the multi-blog “bob” wp-content folder, and select it in the “joe” admin Presentation tab? Then I would have my same old blog back, but running under the bob install, right?

    2. What happens with the different multi-blogs sharing 1 wp-content folder? If someone uses the “upload” function on any of the multi-blogs, will it store ALL the files in the “bob” wp-content folder, for all the sub-blogs?

    2.B. If I do question #1 to put an old blog under the “bob” roof, can I move any random files like photos from the old wp-content into bob’s wp-content, and the links to those JPEG’s will remain valid?

    Thank you extremely very much for this. I wish I had known this method when I started installing multiple copies of WP a couple years ago.

  47. #47 | Posted July 23, 2007 at 9:07 am

    Dgold –

    I should probably separate this instruction set into sections — How to make symbolic links/ how to convert an existing blog, etc…. On to your questions:

    1. You’re working too hard! Just point mb-config-joe.php to the existing database for Joe — assuming it’s on the same server. No import/export needed. If the path to the blog is changing, you might want to use the MySQL utility of your choice to change the path in the joe_options table. (Careful! You have to change it in two places in that table.) If you want the blog to be in the same location as before, you will have to rename the existing /joe/ folder before creating the /joe/ symbolic link to /bob/. When everything is working properly and files are copied over, you can delete the old renamed /joe/ folder.

    2. You are correct that all blogs share a wp-content folder. You can go into Options for each blog and change the upload folder to anything you want (such as /wp-content/uploads/joe/ and /wp-content/uploads/bob/).

    2.B. Yes, you have to move your Joe content into the Bob folder. If you know a bit about mod_rewrite, you can do a rewrite to keep content separate without complicating your links. For example, I use something like this in my .htaccess file:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/(bob|joe)/(demos|downloads|images|archive)/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule /(.*)$ /%1/wp-content/docs/%1/%2/$1 [L]
    </IfModule>
    

    Thus /bob/images/ invisibly reroutes to /bob/wp-content/docs/bob/images/ and /joe/images/ reroutes to /joe/wp-content/docs/joe/images/, and so forth.

    I’ve figured out a few mod_rewrite tricks related to this methodology. I really should do a formal writeup some time…. :-)

  48. #48 | Posted August 2, 2007 at 1:14 am

    [...] thanks to the genius that’s found in the mind of a fellow by the name of Stephen Rider. On his blog, he describes how he was able to install one copy of wordpress and run multiple blogs using [...]

  49. #49 | Posted August 3, 2007 at 8:29 pm

    I’ve managed to set up multiple blogs with one Wordpress install, thanks to your article. However, I’d like the header to be a bit different for each blog. Is there an easy way to go about doing that?

  50. #50 | Posted August 3, 2007 at 9:42 pm

    Billy — Each blog can use a different theme, so you can put whatever you want in the page headers of each theme.

  51. #51 | Posted August 3, 2007 at 10:45 pm

    ok, so if i want the blogs to use the same theme, only use different headers, i’ll need to make a copy of the theme i’m using for each blog and change the header graphics in each (copied) theme directory?

  52. #52 | Posted August 4, 2007 at 9:18 am

    I’ve got my site set with your article as a guide, which is exactly what I was looking. However, I’d like each blog to use the SAME theme, except the header needs to be different, that’s all. The styles and everything else remains the same. So, I was thinking - there should probably be a way to duplicate the header.php file for each virtual blog, modify each header.php, and have each virtual blog use the right header.php.

    The problem is when I change the header.php on the blog that has the actual wordpress files in it, the header also changes on all the virtual blogs. Isn’t there a way of making each of the virtual blogs point to a different header.php file? - something similar to:

    include (TEMPLATEPATH . ‘/header2.php’);

    Hope I’m making sense -

  53. #53 | Posted August 4, 2007 at 9:57 am

    In WordPress there’s a defined constant called ABSPATH, which is directory your current blog is in. So you could do a separate folder for each blog inside your theme folder, and then use something like:

    include (TEMPLATEPATH . '/' . ABSPATH . 'header2.php’);

    Thus the blog in /joe/ would use TEMPLATEPATH/joe/header.php

    With this method a blog at the root level would probably use the header file in the base template folder, but either way you would have to include some PHP logic to avoid a double slash (’//’), as ABSPATH ends with a slash.

    Incidentally, if you want the sidebars to be different in each, try using Widgets instead of hacking the templates.

  54. #54 | Posted August 4, 2007 at 10:00 am

    Actually, Billy, I’m glad you asked that question. Answering you figured out something I’m going to start using myself. :)

  55. Dgold
    #55 | Posted August 4, 2007 at 11:19 am

    Thanks again for this ingenious multiblog technique. (1) Stephen, I think it would be helpful if you highlight mo’s method for making symlinks or insert it in the original post above. (2) I am following Billy’s question because I will want to do the same thing with the header too. Now, I have a new question:

    (3) I want to copy-paste my pre-customized database, into each new multiblog! Is it possible? To explain, I created a master-blog and I want all the sub-blogs to start with my identical 3 categories, 2 usernames and passwords, my custom Hello World post, my custom First Comment, my empty blogroll, and other such details that are stored in the database. I do NOT want each new multiblog to install the standard default WP Hello World post, first comment, Admin username, and randomly generated password. The reason, you can imagine, is the same as the reason for this multiblog technique: to save time and headache of repeated tasks; I don’t want to edit Hello World 20 times. I don’t want to log-in the initial random password and then change it to my admin password 20 times. I don’t want to delete “Uncategorized” and create my same 3 categories, 20 times. I don’t want to go Admin > Blogroll > Delete All, 20 times.

    I don’t know much about MySQL but I can get into PHP-MyAdmin and see my database. I want to store all my multiblogs in 1 database, and each has a different table-prefix (which can be the same as each blog’s folder, for example prefix joe_ and bob_) — I have done it for 3 blogs already using the traditional method of putting my table_prefix in wp-config and then running the Famous 5 Minute Install. Now I want to accomplish the copy-paste described above, and my novice *guess* is that I can copy the table (tables?) of the master-blog, and then paste to a new table with the new prefix… 20 times. Then, kind of reverse of the usual WP install process, I would create the wp-config that points to that database & that table, and make the matching multi-blog with symlinks. Then, again I am guessing, I would log-in to the new multiblog and it would never require the 5-Minute Install, because it is already a pre-written database, already has admin with password, thus looks like it is already installed. WP would never know that I did not run the installer individually for each blog.

    Will this work? Do you see pitfalls in my approach? Any tips, warnings, or reassurances? Most importantly: can you tell me how to copy a table in MySQL (PHP-MyAdmin), and paste the table’s contents into a new table with a new table_prefix? Is there any other unique identifier or hook for each blog, besides the table prefix, that I need to think about?

    Thanks again.

  56. #56 | Posted August 4, 2007 at 11:21 am

    Where exactly am I to place the code:

    include (TEMPLATEPATH . ‘/’ . ABSPATH . ‘header.php’); (with the opening and closing php tags on each end, right?)?

  57. #57 | Posted August 4, 2007 at 9:04 pm

    Billy — presumably, place it in your template file where you want the header to be. You’re the one who suggested the include!

    Dgold — i don’t use PHP-MyAdmin at all — it’s too clunky. I suggest finding a dedicated “real” program that runs on your computer’s OS. On my Mac I use Cocoa MySQL, but there are others.

    I don’t think you would have any problems copying the tables, but BEWARE or fields in the tables that specify directories or table prefixes. You will have to change those manually each time (though depending on the program, you might be able to do a search/replace).

    Again, there are some fields that specify the path to the blog (which will change with each) and there are fields that are named with the table prefix (”wp_” or whatever).

    As long as you’re on top of those, you should be fine just duplicating tables.

    As you’ve partially noted, this method is long overdue for a re-writeup. Busy lately, but I’ll do it one of these days.

  58. #58 | Posted August 10, 2007 at 4:03 pm

    Dgold — check out this link!

    http://wpbits.wordpress.com/2007/08/10/automating-wordp...

    It’s an article describing a way to customize WordPress installations. With this you could easily customize the first post/first comment/categories/users/etc. as you describe above.

  59. #59 | Posted August 11, 2007 at 10:51 am

    I’m *very* familiar with WordPressMU - whioch is more blog farm software, but this this looks like an excellent solution for, not people looking to admin just a few blogs of their own.

  60. #60 | Posted August 16, 2007 at 12:40 am

    I previously suggested to Billy Miles that he use the following code:

    include (TEMPLATEPATH . '/' . ABSPATH . 'header2.php’);

    This will not work, as ABSPATH is the full server path of a file — that is, the path from the root of the hard drive. Not sure how to make it work with the files as-is, actually. It will probably require another constant being defined in the wp-config.php file.

    Sorry ’bout that!

    I’m working on a significant update to this method, that will hopefully resolve some of these issues.

  61. #61 | Posted August 16, 2007 at 3:43 am

    Stephen -

    First of all thanks for the code, and thanks for being the world’s multiple wordpress blogs tech support.

    I implemented your method, combining your instructions with those on Allen Guerra’s site, and the result is a very strange situation in which the VIRTUAL blog seems to work fine, but the ACTUAL blog returns “there doesn’t seem to be a config file” etc. Obviously there is a config file that works well enough to power the virtual blog, so I guess there is a missing pointer or wrong path somewhere for the default blog - but I’ve checked the files against the instructions and fiddled with things a dozen times and I don’t see a problem. Do you have any insight as to where the issue might be to give this result?

    Before doing the multiple install, I had enabled the option of separating the (at that time only) blog directory from the blog homepage, so that even though the blog was in its own directory it could be seen from the standalone domain. I subsequently undid this (I think) because since it deals with paths I thought it might be related to the problem. Is this a suspect?

    Obviously I am no programmer and am not familiar with PHP. Any advice you can give would be appreciated.

  62. #62 | Posted August 16, 2007 at 8:44 am

    All right, never mind, I found it myself on the thirteenth try, a ridiculous misreading of one of the instructions and easily remedied. Thanks again for the code.

  63. #63 | Posted August 31, 2007 at 1:48 pm

    I have been looking for a way to provide our school faculty with multiple blogs in a single WordPress database - and I like what I see here. I am curious as to whether or not with this method of multiple blogs the WordPress search will search all the blogs in a single database or can it be limited to one blog? I would like to think there was a way to select either method. I will confess I am fairly new to WordPress (3-4 months) but can already see its considerable power and flexibility.

  64. #64 | Posted August 31, 2007 at 8:55 pm

    Loren — Search is limited to the particular blog you are in. This method truly runs separate blogs.

    I am actually in the process of trying to figure out a way to search across multiple blogs, but for the moment each blog is a separate entity.

    I am on the cusp of a method of making multiple blogs share User tables. :) Then come cross-blog lists of Pages. Search is my next target after that.

  65. Dgold
    #65 | Posted August 31, 2007 at 9:24 pm

    For a work-around on multi-blog Search you can create a custom Google search-bar that works for your overall domain (or, I think, a custom set of domains). It’s not WP’s Search bar, it’s Google’s retooled for your site.

    Good luck everyone who is using this method & please keep posting the comments, hints and experiences.

    Thanks again Stephen. This really is the ground-breaking easy technique for multi-blogging — all those cross-blog features you talked about are side-candy. The big hurdle is already cleared with this method.

  66. #66 | Posted September 1, 2007 at 10:25 pm

    [...] thing possible?  Well, after looking through the documentation at codex.wordpress.org, I found the Allan Mertner/Stephen Rider symlink hack.  I plan to try to get this running in the next day or two.  However, I’ve had enough [...]

  67. #67 | Posted September 5, 2007 at 5:15 pm

    Can this work with different domains like domain1.com domain2.com?
    The domains files are in /somepaths/domain1 /somepaths/domain2.
    The files belong to the same user on the server.

  68. #68 | Posted September 5, 2007 at 11:28 pm

    it won’t work for multiple domains currently, but I suppose it could be done. Actually, that’s really not a bad idea.

    I’ll see if I can get that working.

  69. #69 | Posted September 6, 2007 at 4:16 am

    [...] echo “Hello Again, World!”; by Stephen Rider [...]

  70. #70 | Posted September 11, 2007 at 7:48 am

    Stephen,

    Your method looks very interesting, and I think will work very well for me. But when I tried to download the zip file your server reported the file wasn’t there.

  71. #71 | Posted September 11, 2007 at 3:17 pm

    Randy — sorry ’bout that. My site is undergoing a major overhaul, and some things aren’t working. The link is fixed now.

  72. #72 | Posted September 13, 2007 at 7:00 pm

    [...] been trying to install multiple wordpress blogs on a single installation for some time [...]

  73. Paul
    #73 | Posted September 24, 2007 at 11:10 pm

    Hi Steve,

    Level: I set up a Wordpress blog and felt like a master of the universe. What does php mean?

    OK, I thought I’d set up a neighborhood blog. It sounds like fun. Then, my wife says we should set up a different blog for a different neighborhood. Then my friend said he wants to join the club. The blogs would have the same theme, but with unique headers, posts, categories, pages etc…

    Am I at the right place? My friend will want to manage his own neighborhood (most likely just the posts) on the blog that I would have set up, but I’m not sure it works like that. Can he do that with your method? So, I thought I’d ask for your guidance.

    There is one other very, very fundamental question I have. I’m imagining that each blog has it’s own administration tools, but I’ve got the feeling that…well, that it is just my imagination.

    Thanks in advance,
    Paul

  74. #74 | Posted September 27, 2007 at 4:38 pm

    Paul — With this method it is exactly as though you have multiple separate installs of WordPress, except that you only have one set of files to maintain/update.

    So… Separate admin, separate users, separate posts, separate everything.

    As for the “use the same theme except different headers” question… there have been a few inquiries about that. any solution at this point will involve tinkering with PHP, and respectfully that goes way beyond what I’m willing to help out with (not being the most skilled PHPer myself…). For the time being, you might check out this thread on the WordPress site, especially my response there (I’m strider72).

    If that’s too much for you, do note of course that each blog will show the different _blog name_ and tagline, per the settings of each blog, so maybe you can do something with that without going “under the hood”.

  75. Paul Welch
    #75 | Posted September 27, 2007 at 9:35 pm

    Stephen,

    Thans for the help. For the record, I find all your comments to be extremely ‘newbie’ friendly. You have the gift.

    Paul

  76. #76 | Posted September 28, 2007 at 12:14 am

    [...] started looking around for ways to make WordPress do multiple blogs with 1 installation.  I found this site that has pretty straightforward instructions on making /blog, /section1, /section2, /section3 all [...]

  77. #77 | Posted October 3, 2007 at 1:40 am

    Stephen - thanks for sharing what seems like an excellent solution to the “i want more blogs” problem. You’ve explained it well enough that even a simple guitar player can understand it (i think…).

    I do have one question, though. I already have a Wordpress blog; what I want to do is copy that blog to a “Laboratory” folder on my server so that I can experiment with different layouts, functionality, etc. without scaring my readers, and then import the successful changes back to my main blog.

    Can I use your method to do this? Thanks for all the help! ~ Mike

  78. #78 | Posted October 3, 2007 at 6:41 am

    Mike — That should work inasmuch as experimenting with themes and plugins goes. One blog will run the active theme and the other will run the experimental. When the experimental theme/plugin is ready for prime time, you just activate it in the “real” blog.

    If you’re talking about transferring _data_ across the two, you’ll need some program for mucking about with MySQL. Your host might provide you with something like phpAdmin for that.

  79. Gate
    #79 | Posted October 4, 2007 at 5:13 pm

    Hello,

    I try to make a subdomain with your solution. I have a domain esourcing.be where I have my default blog.
    I want to add a blog on aiandmusic.esourcing.be.
    Must I finally change PHP_SELF to SERVER_NAME in the file called mb-functions.php?

    All the process works, but I can’t have my blog on the subdomain aiandmusic.esourcing.be it works only on http://www.esourcing.be/aiandmusic

    And in wordpress, must I change the wordpress address and the blog address to aiandmusic.esourcing.be? (when I do that I’ve got an Apache error because he can’t find the address.)

    can someone help me?

  80. Gate
    #80 | Posted October 8, 2007 at 7:23 am

    Hello,

    My first problem isn’t resole, but I’ve found other problem.

    1° I can’t delete the comment and the article that are created by wordpress at the installation (I’ve finnaly delete it in mySQL but I have no ideai i it’s normal)

    2° when I make a search, in the blog http://www.esourcing.be/aiandmusic, it search on http://www.esourcing.be and not in the aiandmusic blog.

    Does anyone have the same problem and is there a solution?

  81. #81 | Posted October 8, 2007 at 6:12 pm

    Thank you for your insight and code. It’s helped me here create team blogs here at xobni.com.

    One quick suggestion - I’m perfectly happy using one DB for all my blogs - as such, an easier construction was to change wp-config.php to *always* look for mb-config-default.php and then change the hard-coded table prefix name (’wp_’) to $user

    That just removes a step when I want to add a new blog, and in fact makes it so the only real thing I need to do is edit wp-config.php and add the username there.

  82. #82 | Posted October 8, 2007 at 10:42 pm

    [...] some googling, I found a unique solution by Stephen Rider, which allows you to symlink multiple directories to a single wordpress install. I changed a few things, introducing svn updates and a simpler blog replication process. I will [...]

  83. #83 | Posted October 9, 2007 at 11:41 am

    Bryan — Nicely Done! I can’t believe I hadn’t thought of that! :)

    Gate — I’ll be the first to admit that the subdomain code hasn’t been thoroughly tested. (That is to say, I haven’t tested it at all. Presumably it’s original author, Allen, did so when he first wrote it.)

    Regarding your problem deleting the default First Post, I can’t imagine what that could possibly have to do with this methodology. Sounds like you’re having database problems to me.

    Did you give your different blogs different databases or table-prefixes?

  84. #84 | Posted October 9, 2007 at 1:35 pm

    First of all, thanks to take a little of your time to answer me.

    For the subdomain I have give up.

    I have one database with two differents prefix.

    here is my code for the blog http://www.esourcing.be/aiandmusic
    file name : mb-config-aiandmusic.php

    
    // ** MySQL settings ** //
    define('DB_NAME', 'gate_esourcing');    // The name of the database
    define('DB_USER', '***');     // Your MySQL username
    define('DB_PASSWORD', '$$'); // ...and password
    define('DB_HOST', 'localhost');    // 99% chance you won't need to change this value
    
    // You can have multiple installations in one database if you give each a unique prefix
    $table_prefix  = 'wp_aiandmusic_';   // Only numbers, letters, and underscores please!
    
    

    and for http://www.esourcing.be
    file name : mb-config-default.php

    
    // ** MySQL settings ** //
    define('DB_NAME', 'gate_esourcing');    // The name of the database
    define('DB_USER', '***');     // Your MySQL username
    define('DB_PASSWORD', '$$$$'); // ...and password
    define('DB_HOST', 'localhost');    // 99% chance you won't need to change this value
    
    // You can have multiple installations in one database if you give each a unique prefix
    $table_prefix  = 'wp_esourcing_';   // Only numbers, letters, and underscores please!
    
    
  85. #85 | Posted October 10, 2007 at 12:57 pm

    Gate — check out this comment regarding subdomains. Let me know if it works! :)

  86. #86 | Posted October 10, 2007 at 1:41 pm

    Sorry Stephen but it works without subdomain, now all is configured and I have sent my address to several directory so don’t really want to change this now.

    any idea why my search function search my other blog?

    Thanks,

    Gate

  87. #87 | Posted October 10, 2007 at 2:00 pm

    No, I don’t. It might be a problem with the theme you’re using. As a test, switch a blog to the default theme and see if the problem goes away.

    Like the starting posts problem, I don’t see how multiblog might change the search function. Check your theme first and let’s see what happens….

  88. #88 | Posted October 14, 2007 at 12:00 pm

    well, when I’m change the theme, the search seems to search on aiandmusic, but there is an error:

    WordPress database error: [Table 'gate_esourcing.wp_aiandmusic_post2cat' doesn't exist]
    SELECT SQL_CALC_FOUND_ROWS wp_aiandmusic_posts.* FROM wp_aiandmusic_posts LEFT JOIN wp_aiandmusic_post2cat ec3_post2cat ON ec3_post2cat.post_id=id LEFT JOIN wp_aiandmusic_ec3_schedule ec3_sch ON ec3_sch.post_id=id AND ec3_sch.end>=’2007-10-14 00:00:00′ WHERE 1=1 AND (((post_title LIKE ‘%massif%’) OR (post_content LIKE ‘%massif%’))) AND post_type = ‘post’ AND (post_status = ‘publish’ OR post_status = ‘private’) AND (ec3_sch.post_id IS NOT NULL OR ec3_post2cat.category_id!=34) ORDER BY post_date DESC LIMIT 0, 10

    can anyone help me?

  89. #89 | Posted October 14, 2007 at 11:28 pm

    Gate –It sounds as though you’re having problems unrelated to multiblog. The post2cat table disappeared as of v2.3 of WordPress, but something in your site is still looking for it. Perhaps a plugin that needs to be updated? (Is your search the default, or a plugin or something? Are you using the default theme or a third-party theme?)

    Perhaps you should try your luck at the WordPress forums — I’m pretty sure your search issues are not related to multiblog.

  90. #90 | Posted October 15, 2007 at 10:01 am

    Thank you very much Stephen,. Now all is working thanks to you, it was a problem with my eventcalandar3 plugin.

  91. #91 | Posted October 15, 2007 at 9:28 pm

    Thought so. When in doubt, one of the first things to try is disabling your plugins. if that fixes it, re-enable one by one until it breaks again….

  92. #92 | Posted October 23, 2007 at 10:25 am

    After playing around with several different setups suggested on the web for doing this, I managed to come up with my own.

    It does not require symlinks, or special .httaccess edits. Instead you only have to edit the wp-config file. And add a little code:

    Just copy the wordpress files into one folder as per usual install of one blog, and when you edit the wp-config file, make the following changes:

    $web = str_replace(”www.”, “”, $_SERVER['HTTP_HOST']);

    switch ($web) {

    case ‘1stdomain.com’:
    // db information for 1stdomain.com goes here;
    break;
    case ‘2nddomain.com’:
    // db information for 2nddomain.com goes here;
    break;
    case ‘defaultdomain.com’:
    // db information for defaultdomain.com goes here;
    }

    The domains will share the plugin and theme files, but since their selection/activation and each blogs settings are stored db side, it will allow you to make sure that each has its own content, look, and plugins activated. When you update your one I have not tested this exhaustively, so it may break with some plugins, but it shouldn’t.

    Alternatively, if your blog structure is laid out like this: blog1.domain.com blog2.domain.com blog3.domain.com You only have to make one change to the code:

    Replace the first line with $web = $_SERVER['HTTP_HOST'];

    Hope this is helpful!

  93. #93 | Posted October 23, 2007 at 12:47 pm

    Trey — It’s a nice methodology, though it might get unwieldy if someone has a _lot_ of blogs (such as a “blog farm” site). I’ve been updating my system, and might just roll aspects of your version into it. Combined with Bryan’s idea there is a LOT of flexibility with that sort of thing.

    The symbolic links, as you observed, are not needed if you’re doing domain-based blogs. They are necessary if doing directory-based blogs, such as I do on this site (/blog/ and /nerdaphernalia/)

    In fact, the more I look at this type of concept, I’m seeing ways to eliminate the need to ever edit the config file, even with the directory-based version that I use.

    The ultimate would not require the user to add any files _at all_, but allow power users the flexibility to use separate config files if they choose to.

  94. #94 | Posted October 23, 2007 at 3:06 pm

    [...] one that I settled on is called virtual blogs by Stephen Rider.  The solution as described by Stephen depends on symbolic links (or [...]

  95. #95 | Posted October 23, 2007 at 3:26 pm

    Funny you should suggest that :-). I’ve been playing around with your solution and when I read Bryan’s simple modification it caused some stray brain cells to fire. I’ve made quite a few modifications to your solution which provide the following features:
    Single configuration file with option to use other config file if you need it.
    Support multiple domains and virtual folders at the same time.

    My solution still requires that you modify the config file for each site. I ended up not using Bryan’s idea to default the table prefix. I’m sure there are other improvements that can be made to this to further reduce the number of changes required to the file system. What would be cool is a plugin model that would allow you to add sites through admin UI.

    By the way, I found that the code that used the mb_config_NF() function didn’t display the message properly. The function needed to declar $mbpath as a global, and the die() function doesn’t take a string.

    Anyway, thanks so much for your good work here.

  96. #96 | Posted October 24, 2007 at 2:28 pm

    The link to download my changes was broken as I recently moved my blog and the download manager templates