How to create a DokuWiki farm
Let’s see how to install DokuWiki, create a farm of wikis and run it privately i.e. with our wikis not being reachable from the Internet.
I assume you have an Apache web server and PHP-7 running on your box. I’ve done my installation on a Ubuntu box.
Install the wiki
First we download the tarball from here and uncompress it. The result is a directory called dokuwiki
. Then follow the steps:
$ sudo mv /home/vicent/Downloads/dokuwiki /var/www/dokuwiki
$ cd /var/www
$ sudo chown -R www-data:www-data dokuwiki
$ sudo a2enmod rewrite
Then, using /etc/apache2/sites-available/000-default.conf
as a template, we create and enable the following virtual host (/etc/apache2/sites-available/dokuwiki.conf
)
<VirtualHost *:80>
ServerName dokuwiki
ServerAdmin webmaster@localhost
DocumentRoot /var/www/dokuwiki
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Then edit /etc/hosts
and add the line:
127.0.0.1 dokuwiki
and restart the Apache service:
$ sudo systemctl restart apache2
Finally run the installation script with the web browser:
http://dokuwiki/install.php
Just fill the fields (it is pretty easy) and you are done 🙂 Now you can run your wiki at http://dokuwiki
About the farm
Suppose that you want to have a wiki for every member of your family (for instance you, your wife and your daughter). Of course you can do it simply creating and organizing properly pages on your wiki instance. But just for fun you can also create a farm of wikis with three independent wikis: one for you, one for your wife and one more for your daughter.
Let’s see how to manually set up a farm of wikis. Usually there is only one farm per server. The farm is made of a farmer (the actual DokuWiki installation, described in the previous section) and one or more animals (i.e. individual wiki instances). The setup of a farm directory is what is needed to start farming. Our setup will be:
/var/www/dokuwiki -> the dokuwiki engine
/var/www/farm -> the dokuwiki farm directory which contains the animals
In the farm directory we can have as many animals as we like:
/var/www/farm/wiki_1 -> one wiki
/var/www/farm/wiki_2 -> another wiki
There are two different setups: virtual host
based and .htaccess
based. We will use the first one. Its main advantage is that it can create much more flexible URLs which are independent of the underlying file structure. The disadvantage is that this method requires access to the the Apache configuration files.
Beware that in our case (a wiki running locally, not visible from the Internet) the mentioned advantage is not really important and the disadvantage simply doesn’t apply.
To access the farm from your local machine you have to edit the /etc/hosts
file as described above
Create the farm directory
Create an empty directory named /var/www/farm
. That will be the farm directory and needs to be writeable by the web server.
$ sudo mkdir /var/www/farm
$ sudo chown -R www-data:www-data /var/www/farm
$ sudo chmod -R ug+rwx /var/www/farm
$ sudo chmod -R o-rwx /var/www/farm
Activate the farm
This is easy too.
$ sudo cp /var/www/dokuwiki/inc/preload.php.dist /var/www/dokuwiki/inc/preload.php
Open that file, uncomment the two relevant lines and set the farm directory:
if(!defined('DOKU_FARMDIR')) define('DOKU_FARMDIR', '/var/www/farm');
include(fullpath(dirname(__FILE__)).'/farm.php');
Add an animal
Download the animal template and extract it in the farm directory. The archive contains a directory called _animal
which includes an empty data
and a pre-filled conf
directory. Rename the directory. Beware that virtual host setup needs animal directory names that reflect their URL e.g. the URL vicent.uvemas.org
works with a directory named vicent.uvemas.org
.
In your /etc/hosts
file you should add the line
127.0.0.1 vicent.uvemas.org
Virtual Host Based Setup
For this setup we create and enable a new site in /etc/apache2/sites-available
for each new animal. For example for vicent.uvemas.org
we will create the file vicent.uvemas.org.conf
with the following content:
<VirtualHost *:80>
ServerName vicent.uvemas.org # this is the URL of the wiki animal
ServerAdmin webmaster@localhost
DocumentRoot /var/www/dokuwiki # the document root always needs to be the DokuWiki *farmer* directory
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Now you should be able to visit the animal’s URL e.g. http://vicent.uvemas.org
and enjoy your wiki.
Change the admin password
As the animal template includes a default admin
user account with the password admin
we should change that password as soon as possible and change the admin’s email address too.
I will stop here but there are a lot of things that you can do now: setup ACLs, install plugins, create namespaces… Please visit the DokuWiki website. There you will find tons of info about everything.