July 2, 2009

Farming

Welcome to the farm! This dokuwiki installation is now part of a wiki farm that also contains http://pam.pesartain.com, http://www.src2pkg.net and http://pq.pesartain.com. One core wiki serves that lot, and whatever other wikis I chose to create on the way.

What I wanted was:

  • One wiki to rule them all, for centralised maintenance - /farmer

  • One wiki at the root of this domain - /

  • As many wikis as I like located at /<subdir>, accessed by <subdir>.pesartain.com

First stage in sorting the farm was to use preload.php in /farmer/inc to set the DOKU_CONF define to the local directory where ‘‘conf’’ and ‘‘data’’ are located:

{% highlight php %}

.pesartain.com $animal = $subdirserver[0]; // don't do anything if the animal doesn't exist if(!is_dir($farmdir . '/' . $animal)) nice_die("Sorry! This Wiki doesn't exist!"); if(!defined('DOKU_CONF')) define('DOKU_CONF', $farmdir . '/' . $animal . '/conf/'); } {% endhighlight %} Stage two is symlinking the resources bin, inc, lib, .htaccess, doku.php, feed.php, index.php and VERSION into the directory that currently contains data and conf. Finally, tweak the update message in conf/msg so the version is properly reflected and call it done. A rough guide is as follows: * Create farmer (unpack dokuwiki) * Disable plugin installation from animals (touch farmer/lib/plugins/plugin/disabled) * Add preload.php to farmer * Add .htaccess to farmer * Create animal template (copy data & conf, symlink the farmer dirs) * ln -s ../farmer/{bin,inc,lib,.htaccess,doku.php,feed.php,index.php,VERSION} . * Link root directory *ln -s farmer/{bin,inc,lib,.htaccess,doku.php,feed.php,index.php,VERSION} . * To sort out the update messages: * template: * cd animal-template/conf * ln -s ../../farmer/conf/msg conf/msg * root: * cd conf * ln -s ../farmer/conf/msg conf/msg * Add plugins to farmer/lib/plugins * Add templates to farmer/lib/tpl * Fix up .htaccess for your associated domains While I was rummaging around sorting the farm, I thought it was about time to provide a canonical domain name: pesartain.com. Note the lack of www. The general mod_rewrite technique for stripping www can also be used to ensure that subdomains are also properly formatted: ## Make pesartain.com cannonical, omit www everytime RewriteCond %{HTTP_HOST} ^www\.(.*)pesartain\.com$ [NC] RewriteRule ^(.*)$ http://%1pesartain.com/$1 [NC,R=301,L] Conversely, src2pkg.net should be fixed with the www, and you really, really, shouldn't be reading it from anywhere except www.src2pkg.net. The rewrite condition here conveniently also operates on src2pkg.pesartain.com too. ## This is for actual domains on subdomains RewriteCond %{HTTP_HOST} ^src2pkg\.(.*)$ [NC] RewriteRule ^(.*)$ http://www.src2pkg.net/$1 [R=301,L] Having a few login problems, however, but so far so good. Edit: It seems this is basically just a symlink farm, which is good enough for me. Even with the [required patch](http://mojito.u-strasbg.fr/farm/.hg/patches/farm0) for the lib/exe/* functions, it's still a grand improvement over what I started with.

Creative Commons License · rational human by Pieter Sartain is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License