Tags:
create new tag
view all tags
I was just thinking about running single code, multiple data (several different TWiki sites, all with the same basic config, running off a single set of code). This has been asked for at various points in the past.

I'm wondering why this isn't trivial. Here's a little Cookbook approach to doing this (Dakar release only, though I guess you could do the same in Cairo)

Let's say you want to run two TWiki sites, one for "cats", and another for "dogs". You want two different URLs: http://animaux.com/dogs/view and http://animaux.com/cats/view. So you set up your httpd.conf as follows:

ScriptAlias /dogs/ "/twiki/dakar/bin"
ScriptAlias /cats/ "/twiki/dakar/bin"
Alias /dogs/ "/twiki/dogs/bin"
Alias /cats/ "/twiki/cats/"
Now, these two URL paths point to the same path, but the request URL is different in each case. The request URL can be recovered via an environment variable, so you can use that in LocalSite.cfg to personalise the configuration:
$TWiki::cfg{DefaultUrlHost} = 'http://animaux.com';
$TWiki::cfg{TemplateDir} = '/twiki/dakar/templates';
$TWiki::cfg{LocalesDir} = '/twiki/dakar/locale';
if($ENV{REQUEST_URI} =~ m#/dogs/#) {
    $TWiki::cfg{ScriptUrlPath} = '/dogs/bin';
    $TWiki::cfg{DataDir} = '/twiki/dogs/data';
    $TWiki::cfg{PubDir} = '/twiki/dogs/pub';
    $TWiki::cfg{PubUrlPath} = '/dogs/pub';
} elsif( $ENV{REQUEST_URI} =~ m#/$cats/m) {
    $TWiki::cfg{ScriptUrlPath} = '/cats/bin';
    $TWiki::cfg{DataDir} = '/twiki/cats/data';
    $TWiki::cfg{PubDir} = '/twiki/cats/pub';
    $TWiki::cfg{PubUrlPath} = '/cats/pub';
}
You could 'personalise' all sorts of things; e.g. htpasswd paths. If you want to share dirs - such as the TWiki dir - you simply soft-link that dir into /twiki/cats/data= and /twiki/dogs/data.

There are at least two potential problems with this:

  1. If you use configure to change any of the "personalised" config vars in LocalSite.cfg, it will knacker the personalisation (though any other var should be OK)
  2. I haven't tried it, so I have no idea if it'll work!

-- CrawfordCurrie - 28 Nov 2005

CategoryCookbook

Topic revision: r1 - 2005-11-28 - CrawfordCurrie
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.