Differences

This shows you the differences between two versions of the page.

Link to this comparison view

people:priestdo:tips:multihome_dokuwiki_hacks [2008/02/21 16:07] (current)
Line 1: Line 1:
 +====== Multihome Dokuwiki Hacks ======
 +
 +I use the article by Lukas Ruf on setting up dokuwiki on a mutihomed web server to allow multiple separate wikis to run on one machine. ​ The article is available at [[http://​wiki.lpr.ch/​doku.php/​multihomed]]. ​
 +
 +These are a few things I have done in addition to the suggestions in the article.
 +
 +
 +===== Create a default tar file or script =====
 +
 +You are going to need more wikis than you think. ​ Lukus suggests creating a script. ​ I did it by creating a tar file.  After following the directions in Lukas'​s article but before you populate your new wikispace, temporarily change the name of the data directory to something you would never use for one of your wikis, I used "​pristine-data"​. ​ Now create a tar file of it.   The next time you want to add another wiki, untar the file and change the name.
 +
 +Or if you don't like that idea, here is a slightly more generic version of the script provided on Lukas Ruf's site:
 +
 +<​code>​
 +#!/bin/sh
 +#
 +# my modification of the script by Lukas Ruf for 
 +# setting up new virtual dokuwikis
 +# Greg Priest-Dorman 2008-01
 +#
 +#####################################################​
 +# Change these locations to suit your installation
 +# dokuwiki root directory
 +DRD=/​usr/​share/​dokuwiki
 +# dokuwiki data directory
 +DDD=/​var/​lib/​dokuwiki
 +# an existing wiki directory to copy the wiki syntax pages from 
 +OLD="​data"​
 +# user:group of web server
 +WUG="​www-data:​www-data"​
 +if [ $# -lt 1 ]
 +    then
 +    echo "Usage $0 NEW_DIR_NAME"​
 +    echo "​Script does almost no error checking."​
 +    echo "​Please give it only well formed directory names."​
 +    echo " "
 +else
 +NEW=$1
 +if [ -e $DDD/$NEW -o -e $DRD/$NEW ]
 +    then
 +    echo "$NEW exists, exiting"​
 +    exit 1
 +else
 +    umask 027
 +    mkdir -p -m 2700 $DDD/​$NEW/​attic $DDD/​$NEW/​cache $DDD/​$NEW/​locks $DDD/​$NEW/​\media/​wiki $DDD/​$NEW/​meta $DDD/​$NEW/​pages/​wiki $DDD/​$NEW/​pages/​.views
 +    touch $DDD/​$NEW/​changes.log
 +
 +#
 +# comment out next 2 lines if you don't want the "​wiki"​ directory with the syntax pages built
 +
 +    cp -r $DDD/​$OLD/​pages/​wiki/​* $DDD/​$NEW/​pages/​wiki/​
 +    cp -r $DDD/​$OLD/​media/​wiki/​* $DDD/​$NEW/​media/​wiki/​
 +#  ​
 +# add .htaccess
 +    echo "order allow,​deny"​ > $DDD/​$NEW/​.htaccess
 +    echo "deny from all" >> $DDD/​$NEW/​.htaccess
 +
 +# next line needed to get group sticky everyware...
 +    chmod -R g+s $DDD/$NEW
 +# make sure owner and group are correct as well
 +    chown -R $WUG $DDD/$NEW
 +# link it in to dokuwiki root
 +    ln -s $DDD/$NEW $DRD/$NEW
 +    echo "​Remember to create and edit your conf file and template"​
 +fi
 +fi
 +</​code>​
 +
 +
 +
 +===== Default config =====
 +
 +If a name gets to the wiki that does not have a conf file associated
 +with it the user gets access to the defaults in the conf/​dokuwiki.php
 +file.  In my case they got to my primary wiki space (in ./data) but
 +bypassed the acl'​s. ​ Not a good option. ​ To add a default behavior use  the lines below in your local.php. ​ They are a slight modification of Lukas'​s
 +
 +<​code>​
 +/*
 + * set your default wiki configuration with $mydefaulthostconfig
 + * make sure it exists and is readable as this will get loaded
 + * if there is not a match.
 + *
 + */
 +
 +$mydefaulthostconfig = DOKU_INC.'​conf/​conf.wiki.cs.vassar.edu.php';​
 +$myhostname ​  = preg_replace('/:​.*$/','',​$_SERVER['​HTTP_HOST'​]);​
 +$myhostconfig = DOKU_INC.'​conf/​conf.'​.$myhostname.'​.php';​
 +if (!is_readable($myhostconfig)) {
 +   ​$myhostconfig = $mydefaulthostconfig;​
 +}
 +@include_once($myhostconfig);​
 +
 +</​code>​
 +
 +
 +
 +===== favicon hack =====
 +
 +This time I wanted each virtual to be able to have it's own
 +favicon.ico file.
 +
 +I decided that the favicon.ico for each wiki should live in the top
 +level of each wiki's media directory. ​ If you want users to be able to
 +upload favicon.ico files you would need to add ico as a mime type to
 +the mime.conf file.  In my case that was not an issue.
 +
 +For each template search the php files in the DOKU_TPL directory
 +(''/​usr/​share/​dokuwiki/​lib/​tpl/​TEMPLATE_NAME''​ in my case) for lines containing:
 +
 +   ​href="<?​php echo DOKU_TPL?>​images/​favicon.ico"​
 +
 +and replace them with
 +
 +   ​href="<?​php echo DOKU_BASE?>​_media/​favicon.ico"​
 +
 +Now put the favicon.ico that you want used in the media directory of
 +each virtual wiki and that is the one that will be served.
 +
 +This hack will of course have to be repeated any time the template is
 +upgraded or changed.
 +