From: Matthew P. <mp...@de...> - 2004-05-21 23:23:28
|
On Sat, May 22, 2004 at 10:18:59AM +1200, Jim Cheetham wrote: > How difficult would it be to virtualise the entire wiki? I'd like to be > able to install the Debian package once, probably into > /usr/share/phpwiki/ ... and then in various VirtualHosts be able to > declare a (uniquely-named) wiki, that would be able to pick a different > config file (and possibly a different 'additional lib' for plugins) ... As it stands, it wouldn't be particularly simple, because PHPWiki does everything from it's index file, which is hardcoded to look for it's config file in one place. We need to tell index.php to get it's config from different places depending on which virtual instance invoked it for this particular run. What I have just recently done for another project is to create multiple configuration instances by indexing a config file by a unique substring of the URL. So, if you've got two PHPWiki sites http://www.site.com/wiki and http://www.site.com/otherwiki, your config sections would be linked to '/wiki' and '/otherwiki'. Similarly, If they're on different virtual hosts entirely, you can have your sections as 'site1.com' and 'site2.com' if they're the unique substrings. This is cute because it requires nothing more than to set up another section in your config file for the new vhost and add an alias. It's a PITA for PHPWiki because it would almost certainly mean a new config file to handle the substring => config file mapping, as you wouldn't want multiple PHPWiki configs in the one file (it'd be a little long and confusing). Another method, if you wanted it, that would work in PHPWiki more or less as-is, would be to use the other method I devised for the above project (which I didn't use as the substring method was more appropriate in that case). Create a constant, perhaps called __CONFIGURED, that will be defined true once all of the appropriate config statements have been processed. Then, tell index.php not to call IniConfig() (or tell IniConfig() not to do anything) if __CONFIGURED is defined. How does this help? Because you put something like the following in your apache.conf for each of the virtualised PHPWiki instances: php_value auto_prepend_file /some/config/file.php Where /some/config/file.php is unique for each instance, and contains pretty much the following code: require_once '/usr/share/phpwiki/lib/IniConfig.php'; IniConfig('/some/config/file.ini'); define('__CONFIGURED', true); Again, where /some/config/file.ini is unique to that virtual instance of PHPWiki and filled with lovely local-specific config options. You then point each virtual instance of PHPWiki at /usr/share/phpwiki for it's code, index.php runs for everyone but skips the default config for your virtual instances because __CONFIGURED is defined, and IniConfig() has previously run with your per-instance config file. If you're interested in using this method (which I think may be the better option for PHPWiki), I'm happy to patch index.php in Debian to support this, as it doesn't break anything in the default case (single instance, config in /etc/phpwiki/config.ini). - Matt |