Tutorials

How to setup a DokuWiki using a Debian 7 Wheezy VPS

How to install DokuWiki on Debian Wheezy with Nginx

DokuWiki is very simple to use open-source wiki software that doesn’t require a database and it is mainly aimed at creating documentation of any kind. To install DokuWiki on a virtual server with Debian Wheezy follow the very easy steps described below. The installation instructions should apply to any Debian based server with Nginx and PHP-FPM installed on it.

All commands assume you are root, if not, then prepend with sudo ie: sudo apt-get update.

Make sure your Debian VPS is up-to-date:

   apt-get update
   apt-get upgrade

‘apt-get update’ will refresh your package list so it’s all up to date, then the upgrade will upgrade any packages that have newer versions.

Install Nginx and PHP-FPM using the following command:

   apt-get install nginx php5-fpm php5-cli php5-mcrypt php5-gd

Create a link to www in a standard location and create domain dir. (The link to /var/www is optional, but be sure to replace the path in the config below if you do not. I switch across multiple platforms and like /var/www to be the default path for scripting etc.)

   ln -s /usr/share/nginx/www /var/www
   mkdir /var/www/yourdomain.com

Download and unpack the latest version of DokuWiki available at http://download.dokuwiki.org :

   cd /var/www/yourdomain.com
   wget http://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz -O dokuwiki.tgz
   tar -xvf dokuwiki.tgz
   mv dokuwiki-20xx-xx-xxx dokuwiki

Create a new Nginx server block. For example, create a new Nginx configuration file to the ‘/etc/nginx/sites-available’ directory:

   vi /etc/nginx/sites-available/yourdomain.com

and add the following content:

   server {
   server_name yourdomain.com;
   listen 80;
   root /var/www/yourdomain.com/;
   access_log /var/log/nginx/yourdomain.com-access.log;
   error_log /var/log/nginx/yourdomain.com-error.log;
   index index.php index.html doku.php;
   location ~ /(data|conf|bin|inc)/ {
   deny all;
   }
   location ~ /\.ht {
   deny  all;
   }
   location ~ \.php {
   fastcgi_index index.php;
   fastcgi_split_path_info ^(.+\.php)(.*)$;
   include /etc/nginx/fastcgi_params;
   fastcgi_pass unix:/var/run/php5-fpm.sock;
   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
   }
   }

Create a symbolic link using the following command:

   ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/yourdomain.com

The webserver user (www-data) needs to be able to write to ‘data’ , ‘conf’ and ‘lib/plugins/’ directories, so you can easily accomplish that by executing the following commands:

   for i in local.php local.php.bak users.auth.php acl.auth.php plugins.local.php \
   plugins.local.php.bak; do chown -R www-data:www-data /var/www/dokuwiki/conf/$i; done

   chown -R www-data:www-data /var/www/dokuwiki/data
   chown -R www-data:www-data /var/www/dokuwiki/lib/plugins/

Restart the Nginx web server for the changes to take effect:

   /etc/init.d/nginx restart

Open http://yourdomain.com/install.php in a web browser. Enter the following information: your site name, username, password and email address for the admin user, then click ‘Save’.

Once the installation is complete, our recommendation is to install ‘captcha’ and ‘preregister’ plug-ins in order to protect the registration against spam bots which create a huge amount useless fake users.

Delete the install script:

   rm /var/www/yourdomain.com/install.php

That is it. The DokuWiki installation is now complete.

Be sure to setup your security settings and visibility.