How to create a DokuWiki farm with symlinks

Here I describe the symlink approach to create a dokuwiki farm. This wiki was created using this approach.

Features of this Approach

  • Quite simple
  • Only the directories conf/ and data/ are copied, all other files are referenced through symlinks (only ~996K initial size per animal)
  • You have to upgrade only one DokuWiki instance and all templates and plugins are available for all instances.
  • Individual configuration per animal
  • Virtual hosts supported
  • Animals can be located in an arbitrary folder (in contrast to the other approach).

Installation of the Farm Wiki

This is the only complete instance of DokuWiki.

  • Run all commands in the following as root (under debian sudo -i).
  • Adapt $farmpath.
  • Adapt the link to the dokuwiki archive.
# path to the farm (ends without /):
farmpath=/var/www/dokuwiki-farm
cd `dirname $farmpath`
# adapt the link for an other version:
wget http://www.splitbrain.org/_media/projects/dokuwiki/dokuwiki-rc2010-10-07.tgz
tar -xzvf dokuwiki-*.tgz
# rename the folder from dokuwiki-YYYY-MM-DD to your farm folder name:
mv dokuwiki-*/ $farmpath
cd $farmpath
chown -R www-data:www-data data/ conf/
cat > inc/preload.php <<'EOF'
<?php
$dir = dirname($_SERVER['SCRIPT_FILENAME']);
if(is_dir($dir . '/conf'))
	define('DOKU_CONF', $dir . '/conf/');
else {
	$dir = preg_replace('#lib/(exe|plugin.*)#', 'conf/', $dir);
	if(is_dir($dir))
		define('DOKU_CONF', $dir);
}
?>
EOF
# the next step is only needed for the older dokuwiki-2009-12-25c!
cp lib/exe/indexer.php{,.orig}
patch lib/exe/indexer.php <<'EOF'
263,265c263,265
< 
<     if(@file_exists(DOKU_INC.$sitemap)){
<         if(!is_writable(DOKU_INC.$sitemap)) return false;
---
>     $sitemap_path=DOKU_CONF.'../';
>     if(@file_exists($sitemap_path.$sitemap)){
>         if(!is_writable($sitemap_path.$sitemap)) return false;
267c267
<         if(!is_writable(DOKU_INC)) return false;
---
>         if(!is_writable($sitemap_path)) return false;
270,271c270,271
<     if(@filesize(DOKU_INC.$sitemap) &&
<        @filemtime(DOKU_INC.$sitemap) > (time()-($conf['sitemap']*60*60*24))){
---
>     if(@filesize($sitemap_path.$sitemap) &&
>        @filemtime($sitemap_path.$sitemap) > (time()-($conf['sitemap']*60*60*24))){
303c303
<     io_saveFile(DOKU_INC.$sitemap,$data);
---
>     io_saveFile($sitemap_path.$sitemap,$data);
EOF

Now you can configure your dokuwiki-farm as you like. The configuration will be the template for the animal wikis.

Disabling Plugins for each Animal individually

With this patch, the plugins are disabled based on the existence of the file conf/plugin.{$pluginname}.disabled. Note, that all previously disabled plugins get enabled by application of the patch, since the former mechanism is ingored.

  • Adapt $farmerpath (same as above).
cd $farmerpath/inc
cp -a plugincontroller.class.php plugincontroller.class.php.dist
patch -p0 plugincontroller.class.php <<'EOF'
--- plugincontroller.class.php.dist	2010-01-17 11:35:46.000000000 +0100
+++ plugincontroller.class.php	2010-04-01 14:08:21.000000000 +0200
@@ -104 +104 @@
-            return @unlink(DOKU_PLUGIN.$plugin.'/disabled');
+            return @unlink(DOKU_CONF.'plugin.'.$plugin.'.disabled');
@@ -111 +111 @@
-            return @touch(DOKU_PLUGIN.$plugin.'/disabled');
+            return @touch(DOKU_CONF.'plugin.'.$plugin.'.disabled');
@@ -125 +124,0 @@
-
@@ -130 +129 @@
-                }elseif(@file_exists(DOKU_PLUGIN.$plugin.'/disabled')){
+                }elseif(@file_exists(DOKU_CONF.'plugin.'.$plugin.'.disabled')){
EOF

Creation of an Animal Wiki

  • Adapt farmpath (same as above).
  • Adapt animalpath.
create-animal.source
# path to the farm (ends without /):
farmpath=/var/www/dokuwiki-farm
# path to the animal, that should be created (ends without /):
animalpath=/var/www/animal1
mkdir -p $animalpath && cd $animalpath
cp -pr $farmpath/{data,conf} .
# www-data is the webserver user:
chown -R www-data:www-data data/ conf/
ln -s $farmpath/{index.php,doku.php,feed.php,inc,lib} .
cat >> conf/local.php <<'EOF'
\$conf['savedir'] = '$animalpath/data';
EOF

Configuration of the Apache Virtual Host for the Animal and mod_rewrite

First, we enable URL rewriting with .htaccess file.

  • Adapt $farmpath (same as above).
  • Adapt $animalpath (same as above).
  • Adapt $animalbasedir.
# This is what stands after the domain name http://animal1.example.org/wiki/ (ends without /):
animalbasedir=/wiki
# Turn RewriteEngine on, adapt RewriteBase and create the .htaccess file
sed 's@RewriteBase /dokuwiki@RewriteBase '$animalbasedir'@g' > $animalpath/.htaccess <<'EOF'
## You should disable Indexes and MultiViews either here or in the
## global config. Symlinks maybe needed for URL rewriting.
Options -Indexes -MultiViews +FollowSymLinks
 
## make sure nobody gets the htaccess files
<Files ~ "^[\._]ht">
    Order allow,deny
    Deny from all
    Satisfy All
</Files>
 
## Uncomment these rules if you want to have nice URLs using
## $conf['userewrite'] = 1 - not needed for rewrite mode 2
RewriteEngine on
#
## Not all installations will require the following line.  If you do, 
## change "/dokuwiki" to the path to your dokuwiki directory relative
## to your document root.
RewriteBase /dokuwiki
#
## If you enable DokuWikis XML-RPC interface, you should consider to
## restrict access to it over HTTPS only! Uncomment the following two
## rules if your server setup allows HTTPS.
#RewriteCond %{HTTPS} !=on
#RewriteRule ^lib/exe/xmlrpc.php$      https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
#
RewriteRule ^_media/(.*)              lib/exe/fetch.php?media=$1  [QSA,L]
RewriteRule ^_detail/(.*)             lib/exe/detail.php?media=$1  [QSA,L]
RewriteRule ^_export/([^/]+)/(.*)     doku.php?do=export_$1&id=$2  [QSA,L]
RewriteRule ^$                        doku.php  [L]
RewriteCond %{REQUEST_FILENAME}       !-f
RewriteCond %{REQUEST_FILENAME}       !-d
RewriteRule (.*)                      doku.php?id=$1  [QSA,L]
RewriteRule ^index.php$               doku.php
EOF

Now we configure the virtual host for the animal.

  • Adapt $animalpath (same as above).
  • Adapt $animalhostname.
animalhostname=animal1.example.org
cd /etc/apache2/sites-available
tee $animalhostname <<'EOF'
<VirtualHost *:80>
    ServerName $animalhostname
    DocumentRoot $animalpath/
    <Directory $animalpath>
        Options FollowSymLinks
        AllowOverride All
    </Directory>
</VirtualHost>
EOF
ln -s $animalhostname ../sites-enabled/.
# reload config to enable the virtual host
/etc/init.d/apache2 reload

Enable config:userewrite and set config:basedir appropriately in the conf/local.php.

  • Adapt $animalpath (same as above).
  • Adapt $animalbasedir (same as above).
cd $animalpath
cat >> conf/local.php <<EOF
\$conf['basedir'] = '$animalbasedir/';
\$conf['userewrite'] = '1';
EOF

Comments

 
 
how_to/create_a_dokuwiki_farm_with_symlinks.txt ยท Last modified: 28.11.2010 03:17 (external edit)
Recent changes RSS feed Creative Commons License Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Drupal Garland Theme for Dokuwiki