Musings on a Multiblog WordPress

[fr]

Je réfléchis à comment on pourrait donner à WordPress la capacité de gérer plusieurs blogs avec une installation. Je me heurte à un problème concernant les includes PHP. Feedback et autres idées bienvenues!

[en]

Update June 2007: Try WordPress Multi-User now.

I’ve used Shelley’s instructions using soft links. I tried Rubén’s proof-of-concept, but got stuck somewhere in the middle.

So I started thinking: how can we go about making WordPress MultiBlog-capable? Here is a rough transcript of my thoughts (I’ve removed some of the dead ends and hesitations) in the hope that they might contribute to the general resolution of the problem. I have to point out my position here: somebody with a dedicated server who’s thinking of setting up a “WordPress weblog-farm” (for my pupils, mainly). So I’m aware that I’m not the “standard user” and that my solution is going to be impractical to many. But hey, let’s see where it leads, all the same. Actually, I think I probably reconstructed most of Rubén’s strategy here — but I’m not sure to what extent what I suggest differs from what he has done.

From a system point of view, we want to have a unique installation of WordPress, and duplication of only the files which are different from one blog to another (index.php, wp-config.php, wp-comments.php, wp-layout.css, to name a few obvious ones). The whole point being that when the isntall needs to be upgraded, it only has to be upgraded in one place. When a plugin is downloaded and installed, it only has to be done once for all weblogs — though it can of course be activated individually for each weblog.

From the point of view of the weblogs themselves, they need to appear to be in different domains/subdomains/folders/whatever. What I’m most interested in is different subdomains, so I’ll stick to that in my thinking. (Then somebody can come and tell me that my “solution” doesn’t work for subfolders, and here’s one that works for subfolders and subdomains, and we’ll all be happy, thankyouverymuch.) So, when I’m working with blog1.example.com all the addresses need to refer to that subdomain (blog1.example.com/wp-admin/, etc); ditto for blog2.example.com, blog3.example.com, blogn.example.com (I used to like maths in High School a lot).

As Rubén puts it, the problem with symbolic links (”soft links”) is called “soft link hell”: think of a great number of rubber bands stretched all over your server. Ugh. So let’s try to go in his direction, for a while. First, map all the subdomains to the same folder on the server. Let’s say blog1.example.com, blog2.example.com (etc.) all point to /home/bunny/www/wordpress/. Neat, huh? Not so. They will all use the same wp-config.php file, and hence all be the same weblog.

This is where Rubén’s idea comes in: include a file at the top of wp-config.php which:

  1. identifies which blog we are working with (in my case, by parsing $HTTP_HOST, for example — there might be a more elegant solution)
  2. “replaces” the files in the master installation directory by the files in a special “blog” directory, if they exist

The second point is the tricky one, of course. We’d probably have a subfolder per blog in wordpress/blogs: wordpress/blogs/blog1, wordpress/blogs/blog2, etc. The included file would match the subdomain string with the equivalent folder, check if the page it’s trying to retrieve exists in the folder, and if it does, include that one and stop processing the initial script after that. Another (maybe more elegant) option would be to do some Apache magic (I’m dreaming, no idea if it’s possible) to systematically check if a file is available in the subdirectory matching the subdomain before using the one in the master directory. Anybody know if this is feasible?

The problem I see is with includes. We have (at least) three types of include calls:

  • include (ABSPATH . 'wp-comments.php');
  • require ('./wp-blog-header.php');
  • require_once(dirname(__FILE__).'/' . '/wp-config.php');

As far as I see it, they’ll all break if the calling include is in /home/bunny/www/wordpress/blogs/blog1 and the file to be called is in /home/bunny/www/wordpress. What is wrong with relative includes? Oh, they would break too. Dammit.

We would need some intelligence to determine if the file to be included or called exists in the subdirectory or not, and magically adapt the include call to point to the “right” file. I suspect this could be done, but would require modifying all (at least, a lot of) the include/requires in WordPress.

Maybe another path to explore would be to create a table in the database to keep track of existing blogs, and of the files that need to be “overridden” for each blog. But again, I suspect that would mean recoding all the includes in WordPress.

Another problem would be .htaccess. Apache would be retrieving the same .htaccess for all subdomains, and that happens before PHP comes into play, if I’m not mistaken.

Any bright ideas to get us out of this fix? Alternate solutions? Comments? Things I missed or got wrong? The comments and trackbacks are yours. Thanks for your attention.

17 Comments

  1. eBlog
    Posted 8/11/2004 at 12:49 pm | Permalink

    ASA WP is multiblog I’ll run it.

  2. Posted 8/13/2004 at 9:12 am | Permalink

    This may be helpful: http://wordlog.com/index.php?p=51

  3. Posted 8/22/2004 at 1:34 pm | Permalink

    I’m working on multi blog support and also on getting Smarty into WP too. Smarty is almost working fine, without caching, but the multi-blog stuff is hard if you want to run all the blogs on one host.
    I went for the “thin layer” solution - mod_rewrite rules break up the URL and change URLs so that a “wpblog” variable is set to the name of the blog. A stripped down wp-config includes a wp-blogs/BLOGNAME/wp-config.php and then processing continues.
    Unfortunately, I’m not an expert at writing mod_rewrite rules and it’s proving to be a stumbling block.
    In b2++ I redirect all requests to a redirect.php, but that turned out to be a very complex solution - I needed lots of PHP code to figure out what the URL contained. I’d rather have a thin layer any day!

  4. Posted 9/13/2004 at 11:28 am | Permalink

    Considering multi-blog setup, you should look at the b2evolution.

    It is an advanced blog engine, based on b2/cafelog - the same roots as WordPress.

    In b2evolution the multi-blog feature is included by default and it has been there for some time already. There is also a fine-grained access control per user/blog/operations - you may enable one user to have full access to one blog and no access to other (for example).

    Main developer’s blog (Francois Planque blog) is a fine example of a multi-blog. It also has UTF-8 support, skins (may be different for each blog), hierarchical categories.

    This does not imply you absolutely have to use b2evolution - but even if implementing multi-blog in WP, you may see how it works in b2evo. :)

  5. essdsm
    Posted 10/2/2004 at 1:36 pm | Permalink

    The b2Evolution solution doesn’t appear to be a scalable solution because human beings still have to create multiple blogs. Work in an institution with thousands of students and it just don’t work. In essence we want to take some basic details either from direct user entry or pulled in from authentication/authorization systems and then autogenerate the blog instance, a la Blogger.com

  6. birdboot
    Posted 12/22/2005 at 9:00 am | Permalink

    Did you ever get any further with this? I would like to implement a multiblog solution which enables authenticated users to automatically set up blogs. LDAP authentication would provide all the information needed to do the setup.

  7. Posted 2/4/2006 at 11:09 pm | Permalink

    As to B2E, I’d be fairly careful. I used the multiblog option to separate content and it works very nicely - BUT -
    1) dealing with comment spam was a nightmare since 25% of the time the antispam tool denied me access the antispam page.
    2) simple linking frequently took forever to work correctly
    (In fairness, I never took the time to troubleshoot these two issues, so who knows why it happened)
    3) B2E takes up an awful lot of server load. My webhost (spookymedia.com) told me that several hosts refuse to allow users to run it. Her solution was a server accelerator that worked by using my own bandwidth to cache pages. Thus, using B2E cost me about an eighth of my bandwidth. It was good motivation to move me to WP, though.

  8. Jose Alfredo Muñoz Longinos
    Posted 5/23/2007 at 3:45 pm | Permalink

    I have some questions about of Wordpres MU. How to install on Windows 2003 server for multiblogs. I don’t have experience with blogs.

  9. turox
    Posted 6/20/2007 at 4:23 pm | Permalink

    There’s a way to install multiple blogs in different folders (/domains/www/domain1.com, /domains/www/domain2.com, /domains/www/domain3.com) using separated databases?

    I mean, an automatic installation, I have to install 1,000 WP blogs :( for a customer and I only have 40 blogs installed…

    any advice?

    thanks,

    Turox

  10. turox
    Posted 6/20/2007 at 4:26 pm | Permalink

    of course, i have full access to the server (mysql admin, root password, etc)

  11. turox
    Posted 6/20/2007 at 4:28 pm | Permalink

    i was trying to create a php script to do this, but just got stuck :’(

  12. Posted 6/20/2007 at 4:32 pm | Permalink

    You should probably try http://mu.wordpress.org/ is you have 1000 blogs to set up…

  13. Umesh
    Posted 7/9/2007 at 3:11 pm | Permalink

    Setting up multiple blogs using mu.wordpress.org is fine but what I am looking for is a common user database. I want user authentication to be the same across all blogs. How can we do that in mu.

  14. Posted 9/5/2007 at 10:52 pm | Permalink

    3 years down the road and still some hacking required …

  15. Posted 10/8/2007 at 5:24 pm | Permalink

    Thanks for your guide and information,

    I’ll create multiple blog in my domain,
    Now, I got the guide

    thanks

  16. Posted 3/2/2008 at 5:52 pm | Permalink

    I am hoping someone can advise me as to how to install Worpdress MU on the same url (or a subdomoain?) as my existing Wordpress site. I want to keep my basic existing site on MU but set up a member/sitename area with MU. My MU installation defaults to a 404 page. Can the two programs co-exist?
    Any help would be appreciated.

  17. Posted 3/2/2008 at 5:54 pm | Permalink

    Sorry, I meant keep the existing site with Wordpress, but have the members blogs on MU

8 Trackbacks

  1. By Netlex News on 8/16/2004 at 9:45 am

    Multiblog : une page unique pour de multiples utilisateurs
    Comment créer un “multiblog” avec Wordpress ?

    Allan sur Mertner.com a trouvé une solution qui permet à  chaque utilisateur d’afficher sur le même site Wordpress leurs propres articles.

    via Mertner.Com Family Blogs - An Experiment In Multip…

  2. […] Climb to the Stars (Stephanie Booth) » Musings on a Multiblog WordPress multi-wordpress (tags: wordpress blog) […]

  3. By Chris Brunner .com on 6/9/2006 at 4:13 am

    Switching from b2evolution to WordPress…

    Like many others, I’ve decided to ditch b2evolution in favor of WordPress.’  The biggest reasons were:

    b2evolution has almost no protection against spam.’  They have this goofy little centralized blacklist that’s maintained by one person a…

  4. By Weblog Tools Collection on 8/20/2006 at 10:02 pm

    Stephanie Booth’s Musings on a Multiblog WordPress…

    Climb to the Stars >> Musings on a Multiblog WordPress: Some interesting thoughts there and I could add some of my own but I have been waiting for *********’s proof of concept to surface. I personally believe that rather than trying to re-enginee…

  5. […] WordPress user Stephanie Booth (http://climbtothestars.org) provides instructions on automating the installation of multiple blogs for a weblog farm in her posting, Scripts for a WordPress Weblog Farmhttp://climbtothestars.org/archives/2004/09/02/scripts-for-a-wordpress-weblog-farm). In Musings on a Multiblog WordPress (http://climbtothestars.org/archives/2004/08/11/musings-on-a-multiblog-wordpress/), Stephanie shares her thoughts on the process. ( […]

  6. […] Carthik a fait un résumé de quelques solutions multiblogues pour wordpress. Netlexblogger en a traduit quelques extraits, et Stephanie Booth aussi a touché au sujet. Il s’agit surtout des solutions de Allan et de Ruben. Si vous n’êtes toujours pas convaincu de la flexibilité de wordpress, il y a toujours ce tableau des solutions de blogues qui compare fonctionnalité après fonctionnalité. […]

  7. […] WordPress user Stephanie Booth (http://climbtothestars.org) provides instructions on automating the installation of multiple blogs for a weblog farm in her posting, Scripts for a WordPress Weblog Farm (http://climbtothestars.org/…/scripts-for-a-wordpress-weblog-farm). In Musings on a Multiblog WordPress (http://climbtothestars.org/archives/2004/08/11/musings-on-a-multiblog-wordpress/), […]

  8. […] Here’s some reading regards multi-blog. […]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*
Contact