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:
- Replace the standard wp-config.php file with a new version that calls a different configuration set depending on what directory it’s in.
- 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.

117 Comments
Pages: [1] 2 3 4 5 6 » Show All
[...] 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. [...]
[...] 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-...) and more importantly, (http://www.striderweb.com/nerdaphernalia/2006/10/hello-...). 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. [...]
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!
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
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?
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!
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
my code in the previous comment has loaded invisible
(right after “using the instructions’ example scheme..”)
.. maybe that could be fixed
=)
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.
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.
Stephen, I agree. I have found most plugins incompatible with WordPress MU (as well as templates!). So it is good that we have options.
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
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.
Thanks!
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.
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?
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?
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
err… no. The symlink should point to /bob/ not /bob/wp-content/multiblog/
Thanks, that did the trick for #16. Any ideas on #15?
Pages: [1] 2 3 4 5 6 » Show All