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
[...] 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?
The proper php symlinks code for shared hosting users without unix prompt access.
<?phpsymlink ('/home/userID/public_html/bob','/home/userID/public_html/joe');?>there is a space in between,[no there ain't -- ed]?phpandthat needs to be removed in order for this code to work. (I need it there so this post would show)
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!
there is still some invisible characters above, but I hope you guys figure it out
=)
[...] is a wordpress multiplicity of “Journal” yet using a different database [...]
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 < and > …I think.
Very cool! I just accomplished this for a client’s site and it worked like a charm! Thanks a lot.
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)
[...] 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... [...]
This looks like exactly what I need, but my one burning question is — can I test it on a localhost install using XAMPP?
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!
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.
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!
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.
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!
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)
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...
]
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.
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!
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.
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.
[...] Stephen Rider’s Multiblog zip file – you can download it from here [...]
[...] 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 [...]
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
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
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
#WordPressmarkers, 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.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. ^_^
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.
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.phpto 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 thejoe_optionstable. (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
.htaccessfile:<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….
[...] 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 [...]
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?
Billy — Each blog can use a different theme, so you can put whatever you want in the page headers of each theme.
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?
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 -
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 useTEMPLATEPATH/joe/header.phpWith 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.
Actually, Billy, I’m glad you asked that question. Answering you figured out something I’m going to start using myself.
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.
Where exactly am I to place the code:
include (TEMPLATEPATH . ‘/’ . ABSPATH . ‘header.php’); (with the opening and closing php tags on each end, right?)?
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.
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.
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.
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.phpfile.Sorry ’bout that!
I’m working on a significant update to this method, that will hopefully resolve some of these issues.
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.
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.
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.
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.
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.
[...] 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 [...]
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.
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.
[...] echo “Hello Again, World!”; by Stephen Rider [...]
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.
Randy — sorry ’bout that. My site is undergoing a major overhaul, and some things aren’t working. The link is fixed now.
[...] been trying to install multiple wordpress blogs on a single installation for some time [...]
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
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”.
Stephen,
Thans for the help. For the record, I find all your comments to be extremely ‘newbie’ friendly. You have the gift.
Paul
[...] 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 [...]
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
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.
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?
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?
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.
[...] 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 [...]
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?
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
and for http://www.esourcing.be
file name : mb-config-default.php
Gate — check out this comment regarding subdomains. Let me know if it works!
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
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….
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?
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.
Thank you very much Stephen,. Now all is working thanks to you, it was a problem with my eventcalandar3 plugin.
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….
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!
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.
[...] one that I settled on is called virtual blogs by Stephen Rider. The solution as described by Stephen depends on symbolic links (or [...]
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.
The link to download my changes was broken as I recently moved my blog and the download manager templates needed tweaking. I tested it and it works now. Sorry for the inconvenience.
Update on the update:
I’m in final testing of a significant update to this system, including support for directory, domain, and subdomain-based “virtual” blogs. I’ve also cleaned up the setup files and simplified the wp-config a bit.
Either in this release or soon after, I may include the ability (by default) to have a “no config” setup that simply prefixes the tables based on the current directory (based on Bryan’s suggestion). This would make it work better “out of the box” for non-power users, but allow for individual configurations if needed.
This has been a long time coming. Sorry for the delay — I should have it up this week some time.
Stephen,
This is simply brilliant. I have a need to have one main blog and fifty states blogs that feed into the one. I think your solution will work, but I wanted to run this by you before I attempted to tinker. This is not my art, mine is Raku Clay handmade tiles and conservative thought. I appretiate your artistic use of code to simplify. I was wondering if you would be willing to think this over and give me suggestions if you think this is the way to go. My original site is http://www.theclayempire.com/blog. I am growing the Grizzly Groundswell to have 50 conservative Republican bloggers, one from each state plus a number of Grizzly Groundswell Mayors as Authors from each state as well.
Essentially, my vision is to have one main site http://www.grizzlygroundswell.com The 50 states sites (ex. Minnesota, North Dakota, California etc.) Each state will consist of one Grizzly Groundswell Governor (editor) and many Grizzly Groundswell Mayor’s who will fill the author’s roster for each states blog. Some may have two, others 35 or more!
All 50 blogs will hopefully be able to feed into the main Grizzly Groundswell site. (I have not figured out how to do this yet.) But your multiple blogs concept solution should give me
one main site: Grizzly Groundswell
Minnesota
North Dakota
Arkansas
Etc, etc.
I am currently moving my domains and hosting to Go Daddy and I am setting everything up so there is no pain for my authors, only an updated wordpress to look forward too!
But I would like to utilize your code and expertise to blow them away!
Can you help me?
~Teddy Bear
Ted –
The current download works for this setup:
grizzelygroundswell.com/minnesota/
and so forth.
In the next day or so I expect to release version 2 of this methodology. You might want to work with that. It will additionally allow you to do:
minnesota.grizzelygroundswell.com
or completely separate domains. I’m working on simplifying the setup still, so you might not need to make 50 separate config files.
FYI – each blog has a _completely_ separate administration — it’s like a totally separate install of WordPress. As of yet there is no cross-linking of Users, for example. Another person I know of is working on a WP plugin that allows sharing of User tables, but I don’t think it’s “ready for prime time” quite yet.
Not sure quite what you mean by “feed into the main… site”. the main blog can certainly be made to link to the 50, but I wouldn’t expect direct interactivity. If you want some of the subsidiary blog posts to appear in the main blog, you might look for a WordPress plugin that allows cross-posting. There’s probably something like that out there….
Stay tuned….
Stephen,
This is exciting!
So each blog would be sepperate onto itself? That is pretty amazing! So with on wordpress install, I could host my 51 blogs!
That is simply exciting.
Now I have to figure out if that is what my authors want!
Thanks
Teddy Bear
[...] Nerdaphernalia » echo “Hello Again, World!”; 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. Wi (tags: wordpress multiblog hack php blog) [...]
[...] Stephen Rider’s page on multiblogging [...]
I decided that my changes were big enough that I should have called my solution something else – I shouldn’t have called it MultiBlog2. I’ve now renamed mine as DRP-Multi-Blog.
I’ve also implemented a plugin so that you can display the list of virtual sites using a keyword in post or page content, e.g. [virtual_sites_list]. The plugin supports other keywords as well. Check it out at http://dpotter.net/Technical/index.php/2007/10/29/multi....
I look forward to seeing your next version.
Thanks,
David
Subj: Multiblog : 2nd WP blog does not install
I’ve tried to install two blogs sharing one database follow Stephen’s instructions in multiblog-readme.txt, amplified by instructions from Allen Gurrea
My primary/1st blog located at public_html/cat installed fine.
The 2nd_blog does not install.
I can see my symlink-created-2nd_blog name (“dog” using Allen’s vernacular) in my root directory, but WP does not install using rentor2owner.com/dog/wp-admin/install.php; instead it returns a “404-no file found” like it’s not seeing the file located at rentor2owner.com/cat/wp-admin/install.php
I assume I’m not interpreting something correctly in the instructions, and was hoping someone who had experienced a similar setup problem might set me straight.
I know the bare minimum about pHp and virtual links, but know a space in the wrong place in a pHp script can be a show stopper.
TIA
I’ve just finished a first public release of a new abstraction layer enabling WP users to make use of other PDO supported databses, including SQLite (rathercurious.net).
It seems to me that a SQLite solution would be a perfect adjunct to this multiblog solution. the core of the blog (database) is then kept complete discreet.
My solution currently standardises on a preset name and location but this could be (very – [2 lines]) easily adapted for this solution.
in response to the multiple questions about template differentiation: i suggest that the new version of wp-config set a database variable ($wpdb->multiblogNumber) based on the request. This can then be easily inserted into the template files (such as header) to create a conditional. yes – it’s playing with actual code but not in a difficult manner.
Justin
Wolf –
“[I]nstead it returns a ’404-no file found’ like it’s not seeing the file located at rentor2owner.com/cat/wp-admin/install.php”
I believe what it’s not finding is rentor2owner.com/cat/
There’s not much more I can check without access to your server, nor am I inclined to troubleshoot symlinks. My primary suggestion is to ask your hosting provider to look at the symbolic link for you and confirm that it’s working.
You might try looking at it via FTP as well. Some FTP programs have a setting to “resolve symlinks”, meaning that it treats symlinks as folders. See if the FTP program sees dog as a file or a folder.
Again, your host company is probably your best bet.
Justin –
To distinguish between users, there’s no need for a new variable — just call the existing
get_virtual_user()function.By the way — for anybody waiting on the new version — I had it ready for release, but am still checking a potentially serious security hole.
In my attempts to make v2.0 almost entirely configuration-free, I’ve opened it up to the possibility of hackers hosting their blogs on your server. Oops.
Still checking it out….
[...] installation usable for more than one user. see the wordpress docu for instructions. I choose this approach and hacked a little to get it running on my debian box: – unzip the multiblog.zip in [...]
hello stephen, thanks for your great work here I’ve already put it to great use. I also have a need to display content from multiple blogs on a single page and noticed you are working on a release to do just this.
I haven’t quite figured out the details, but am experimenting with rewriting the $wpdb table names with the correct prefix for the blog I am trying to query at that moment, retrieving the original query string, and then re-calling query_posts with it. I was wondering if you were doing something similar or found a more elegant solution?
Thanks, looking forward to your next release!
I’ve been trying to get a list of pages that combines the pages of multiple blogs. WordPress appears to cache $wpdb in some way I can’t figure out, so no luck so far. It sounds as though what you’re trying is very similar, so let me know if you figure it out.
Stephen : Thanks for your comments in #91 to my scenario in #89. We were both right.
In synch with your advice, I pursued the symlink scenario with HostGator and the great guys there worked overtime to figure out that Allen Gurrea’s symlink instruction wasn’t quite right, at least on their server.
I was on target with the thought that something minor such as a missing space or something-or-other could make all the difference in the world. For my situation, it was a missing forward slash.
Allen’s pHp symlink script “home/user/public_html/cat” didn’t work for me until we added a forward slash upfront to make it “/home/user/public_html/cat”.
Something just that simple ripped more time out of my hide than I want to think about, but it appears to have resolved the issue. So everything looks good and I’m moving forward.
Thanks for your innovative work and the opportunity to post here.
Hi Stephen,
In my I need to display the most recent post from one blog, and then the last 5 posts from two other blogs, and this code seems to do the trick. I do this for each blog I am pulling from:
//map the wpdb table names with the new prefix
$blog_prefix = 'bob_';
global $wpdb;
$wpdb->prefix = $blog_prefix;
$wpdb->posts = $wpdb->prefix . 'posts';
$wpdb->users = $wpdb->prefix . 'users';
$wpdb->categories = $wpdb->prefix . 'categories';
$wpdb->post2cat = $wpdb->prefix . 'post2cat';
$wpdb->comments = $wpdb->prefix . 'comments';
$wpdb->link2cat = $wpdb->prefix . 'link2cat';
$wpdb->links = $wpdb->prefix . 'links';
$wpdb->options = $wpdb->prefix . 'options';
$wpdb->postmeta = $wpdb->prefix . 'postmeta';
$wpdb->usermeta = $wpdb->prefix . 'usermeta';
//reload the query object with posts from new tables
query_posts('showposts=5');//Permalinks and other post-related URLs are prepended with the value of the ‘home’ option
//so we need to override this with the new proper value for the blog we’re pulling from
$old_option = get_option('home');wp_cache_set('home', 'http://www.mysite.com/bob/', 'options');loop over posts…
//Restore the original ‘home’ option so any remaining links render correctly
wp_cache_set('home', $old_option, 'options');Chango –
Your code is _very_ similar to what I was trying to make work.
It appears that the
wp_cache_set()function is what I was missing. I would change the prefix and the$wpdbelements I needed, but returned the first blog’s data twice. I’ll definitely check this out. Thanks!New and improved! This page now includes a Tip Jar!
Well, okay. New and improved for me. I can’t give you guys _all_ the goodies.
Version 2.0 should be up tomorrow. Just some final touches, packaging, and upload.
VERSION 2.0!!!!!
This system now has its own page, rather than being a simple blog entry. As such, comments are closed here. Please leave new comments on the new page.
The new version has _significantly_ improved ease-of-setup, plus working domains and subdomains, new functions for your themes, and a VUSER constant that you can use to specify the current blog (great for customizing themes!)
Check it out!
[...] – this post pretty much explains the theory, a bit like this post – but I actually happened across it [...]