It's better when it's simple

User Tools

Site Tools


Translations of this page?:

Learn about DokuWiki

Advanced Use

Corporate Use

Our Community

Follow us on Facebook, Twitter and other social networks.


DokuWiki Farms

A wiki farm is a collection of wikis running on the same web server and sharing one parent wiki engine. So, by running just one single parent wiki, you can power hundreds of independent other wikis (aka “animals”). All animals share one set of plugins and templates but each of them can have a different set of enabled plugins, a different template and a different configuration. The concept of farms is also called “multi-site”, “multi-domain” or “sub-sites” in the context of other CMS.

There are multiple ways to achieve running a wiki farm. Probably the easiest way is to use the Farmer Plugin which will set up the farm for you and provides means to create and manage the animals.

This page describes how to manually set up a farm in the easiest and most straightforward way to run a wiki farm with DokuWiki. More advanced setups and tips are described on a separate page.


  • When talking about a farm it describes the whole setup containing all of the below. Usually there is only one farm per server.
  • The farmer (aka parent wiki) is the actual DokuWiki installation. This is where all the code resides, where you install plugins and templates and what you will update on new releases. You only have one farmer per farm.
  • The setup of a farm directory is what is needed to start farming. It is the physical parent directory of all the animals on your server. Just one single location on your farm server.
  • The animals (aka child wikis) are the individual wiki instances. This means you can have plethora of these but each one will only contain the wiki data and animal specific configurations, no more code duplication.

Directory Setup

The following example is the most common directory setup and it is used throughout this document. But you can have a very different setup.

  • /var/www/dokuwiki – the DokuWiki engine, this needs to be accessible from the web
  • /var/www/farm – the DokuWiki farm directory which contains all the animals

In your farm directory you can have as many animals as you like, e.g.:

  • /var/www/farm/animal – one wiki
  • /var/www/farm/ – another wiki

Two different setups

There are two different setups: Virtual host based and .htaccess based.

The Virtual host (or 'virtual web server') method combines features of a web-server and the way names are translated to internet addresses to provide access to different farm animals in the wiki farm based on the hostname used in accessing the wiki. In this case, multiple hostnames end up referring to the same web server – “” may provide access to the farmer wiki, while “” may provide access to your wiki with programming tutorials, but they both connect to the same physical machine.

The .htaccess (or 'server script') method only requires features of a webserver to make different file paths refer to distinct wikis. A small script tells the webserver how to handle each wiki's top level directory differently, which allows for independent wikis. In this case, “” could be the start page for my farmer wiki, and “” would access the programming tutorial wiki.

Regardless, both methods require some sort of server configuration.

Virtual host based setup

  • What to configure: virtual hosts via Apache's httpd.conf or your hosting control panel.
  • Resulting URLs: anything, e.g., or
  • Advantages: It can create much more flexible URLs which are independent of the underlying file structure.
  • Disadvantages: The possibility to set up virtual hosts is not always available. Some (especially cheap) hosting providers don't allow it.

For systems you will want to access from elsewhere, you will need to publish the new name for the web server's host. When you want to run this setup, you will need to provide the new hostnames to any machine that might want to access your farms usually configuring a DNS server. If unsure, contact your system administrator or service provider for specific instructions.

To have access from your local machine, you have to edit the local 'hosts' file to make sure that your computer will know its new names. :!: This method only works when connecting from the same machine; other systems will not know the machine's additional names.

For Windows users, you will need to change the file c:\windows\system32\drivers\etc\hosts. In most setups, you will need to have administrator privilege to edit this file.

For Linux and other Unix-like systems, you will need to edit the file /etc/hosts.

For either system, you will want to add:

(Where farm-animal is the name of the new wiki, and is appropriate for your system.)

.htaccess based setup

  • What to configure: .htaccess. Apache also needs to permit htaccess configuration.
  • Resulting URLs: only “subdirectories” of one domain and farm, e.g. or, but with a more complex setup nearly the same flexibility as with the other setup is possible
  • Advantages: If virtual hosts are not supported by the hosting provider, this is the only possible solution.
  • Disadvantages: .htaccess files are not always supported by some hosting providers. But this solution is more likely to be supported than virtual hosts.

How to create a farm

0. Prerequisites

In the following steps we assume you have already installed a standard DokuWiki. Please make sure to either install it properly, so that it works like a normal wiki, or remove install.php for security reasons.

1. Create the farm directory

Create an empty directory named /var/www/farm. That will be your farm directory and needs to be writeable by the web server. That should be protected in the same way you would protect a normal DokuWiki.

2. Activate the farm

In the farmer directory, copy ./inc/preload.php.dist to ./inc/preload.php, open it and uncomment the two relevant lines and set your farm directory, so that it looks like this:

// set this to your farm directory
if(!defined('DOKU_FARMDIR')) define('DOKU_FARMDIR', '/var/www/farm');
// include this after DOKU_FARMDIR if you want to use farms

Note: If you don't have DokuWiki version Adora Belle (2012-10-13) or newer, those two files will be missing. In that case you can simply copy them over from here: farm.php and preload.php.dist.

Note: the path that you enter for DOKU_FARMDIR may need to be based on the “true” path to the server directory (as revealed by the PHP variable $_SERVER['DOCUMENT_ROOT']). Sometimes using a symbolic link does not work. For example, even if you normally access your farm server directory as “/public_html/farm”, you might need to enter something like “/home/<htmlusername>/public_html/farm”.

3. Add an animal

Extract this animal template into your farm directory. It is a directory (called _animal) which includes an (as good as) empty data and a pre-filled conf directory.

Then you need to rename that extracted directory. But the rules how to name the directory in which your animal stores all its files depends on the setup:

  • The virtual host setup needs animal directory names which reflect their URL. E.g. works with a directory named 1)
  • The .htaccess setup needs the animal directory names exactly as they are called in the URL. E.g. would need an animal directory called cat. If you are using a separate .htaccess file for each animal you can specify the animal name there.

In case you're using the .htaccess based setup, you need to uncomment and change your animal's $conf['basedir'] in conf/local.protected.php to the path in the URL under which the animal can be accessed (for example '/animal/' if accessible at – but can be stored in /var/www/farm/animal).

4. Add required server settings

If you're not used to server configuration, this is the only more complicated bit. FIXME This and the following needs elaboration.

a. Virtual Host Based Setup

For this setup you have to configure the virtual host for each new animal in your web hosting control panel or httpd.conf. Here is the httpd.conf example for

NameVirtualHost *
<VirtualHost *>
    ServerName    # this is the URL of your wiki animal
    DocumentRoot /var/www/dokuwiki/     # the document root always needs to be the DokuWiki *farmer* directory

On most shared hosts environments you only need to add the server name (your desired domain with or without subdomain) and the document root (always pointing to the farmer directory) through their GUI.

b. .htaccess Based Setup

This .htaccess file needs to be put into the farm directory. Remember to enable .htaccess in the Apache Configuration (AllowOverride All)

RewriteEngine On
RewriteRule ^/?([^/]+)/(.*)  /dokuwiki/$2?animal=$1 [QSA]
RewriteRule ^/?([^/]+)$      /dokuwiki/?animal=$1 [QSA]
Options +FollowSymLinks

Change the /dokuwiki/ part to the path to the farmer.

5. Change the admin password

You're done, you can now simply go to your animal's URL (either or depending on your setup).

:!: As the animal template includes a default “admin” user account with the password “admin”. Please change the admin password as soon as possible. Just login with admin/admin, go to “Admin” > “User Manager”, click on the admin user and change its password below. You should also change the admin's email address.

How to add more animals

After the initial setup, you only need to repeat add an animal, add required server settings (only in case of a virtual host setup) and change the admin password for each new animal.


You can add questions and requests to the discussion page.

But it would also work with any other of the following directory names: example or
farms.txt · Last modified: 2016-09-02 13:10 by andi