Difference between revisions of "DokuWiki"

From ArchWiki
Jump to: navigation, search
(php.ini adjustements for dokuwiki to work)
m (Enable upload and displaying of SVG files: - add a note that this behavior is disabled by default)
 
(38 intermediate revisions by 16 users not shown)
Line 1: Line 1:
[[Category:Office]]
+
[[Category:Wiki software]]
[[es:Dokuwiki]]
+
[[es:DokuWiki]]
[[zh-TW:Dokuwiki]]
+
[[ja:DokuWiki]]
"DokuWiki is a standards-compliant, simple-to-use wiki which allows users to create rich documentation repositories. It provides an environment for individuals, teams and companies to create and collaborate using a simple yet powerful syntax that ensures data files remain structured and readable outside the wiki."
+
[[zh-hant:DokuWiki]]
 +
"[https://www.dokuwiki.org/dokuwiki# DokuWiki] is a standards-compliant, simple-to-use wiki which allows users to create rich documentation repositories. It provides an environment for individuals, teams and companies to create and collaborate using a simple yet powerful syntax that ensures data files remain structured and readable outside the wiki."
  
 
"Unlimited page revisions allows restoration to any earlier page version, and with data stored in plain text files, no database is required. A powerful plugin architecture allows for extension and enhancement of the core system. See the features section for a full description of what DokuWiki has to offer."[http://wiki.splitbrain.org/wiki:dokuwiki]
 
"Unlimited page revisions allows restoration to any earlier page version, and with data stored in plain text files, no database is required. A powerful plugin architecture allows for extension and enhancement of the core system. See the features section for a full description of what DokuWiki has to offer."[http://wiki.splitbrain.org/wiki:dokuwiki]
Line 8: Line 9:
 
In other words, DokuWiki is a wiki written in PHP and requires no database.
 
In other words, DokuWiki is a wiki written in PHP and requires no database.
  
[http://www.dokuwiki.org/ Like to see a running example?]
+
== Initial notes ==
 
+
DokuWiki should work on any web server which supports PHP 5.6 or later.  As the requirements may change over time, you should consult the [http://www.dokuwiki.org/requirements requirements page] for DokuWiki for additional details.
== Initial Notes ==
 
DokuWiki should work on any web server which supports PHP 5.1.2 or later.  As the requirements may change over time, you should consult the [http://www.dokuwiki.org/requirements requirements page] for DokuWiki for additional details.
 
  
 
It is strongly recommend to read through the appropriate sections of [http://www.dokuwiki.org/security DokuWiki's security page] for your web server.  Most popular web servers are covered but there are generic instructions as well.
 
It is strongly recommend to read through the appropriate sections of [http://www.dokuwiki.org/security DokuWiki's security page] for your web server.  Most popular web servers are covered but there are generic instructions as well.
  
The package in [community] unpacks DokuWiki at {{ic|/srv/http/dokuwiki}} and changes ownership to the "http" user. This should work fine for most popular web servers as packaged for Arch.
+
The package in [community] unpacks DokuWiki at {{ic|/usr/share/webapps/dokuwiki}} with the configuration files in {{ic|/etc/webapps/dokuwiki}} and the data files in {{ic|/var/lib/dokuwiki/data}}. It also changes the ownership of the relevant files to the "http" user. This should work fine for most popular web servers as packaged for Arch.
  
 
== Installation ==
 
== Installation ==
  
# Install your web server of choice (e.g. [[Apache]] or [[lighttpd]]) and configure it for [[PHP]].  As mentioned above, DokuWiki has no need for a database server so you may be able to skip those steps when setting up your web server.
+
# Install your web server of choice (e.g. [[Apache]], [[nginx]] or [[lighttpd]]) and configure it for [[PHP]].  As mentioned above, DokuWiki has no need for a database server so you may be able to skip those steps when setting up your web server.
 
# Install {{Pkg|dokuwiki}} from [community] with [[pacman]].
 
# Install {{Pkg|dokuwiki}} from [community] with [[pacman]].
 
# Configure web server for dokuwiki (see section below)
 
# Configure web server for dokuwiki (see section below)
# With your web browser of choice, open <nowiki>http://&lt;your-server&gt;/dokuwiki/install.php</nowiki> and continue the installation from there.
+
# With your web browser of choice, open <nowiki>http://&lt;your-server&gt;/dokuwiki/install.php</nowiki> and continue the installation from there. For nginx the URL is <nowiki>http://&lt;your-server&gt;/install.php</nowiki>.
  
 
Alternatively, if you would like to install from tarball, you can read from http://www.dokuwiki.org/Install.  Generally the procedure is the same as above.  Instead of using pacman, you will need to [http://www.splitbrain.org/projects/dokuwiki download the tarball], unpack it to your server's document root (e.g. {{ic|/srv/http/dokuwiki}}), and chown to the appropriate user (e.g. "http").
 
Alternatively, if you would like to install from tarball, you can read from http://www.dokuwiki.org/Install.  Generally the procedure is the same as above.  Instead of using pacman, you will need to [http://www.splitbrain.org/projects/dokuwiki download the tarball], unpack it to your server's document root (e.g. {{ic|/srv/http/dokuwiki}}), and chown to the appropriate user (e.g. "http").
Line 28: Line 27:
 
== Configuration ==
 
== Configuration ==
  
 +
If you are using [[lighttpd]] or [[nginx]] and your PHP version is lower than 7, you need to adjust the {{ic|open_basedir}} in {{ic|/etc/php/php.ini}} to include the dokuwiki directories (php forbids following symbolic links outside of the allowed scope):
 +
 +
{{hc|/etc/php/php.ini|<nowiki>
 +
open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/webapps/dokuwiki/:/var/lib/dokuwiki/
 +
</nowiki>}}
 +
 +
Also uncomment the following line.
 +
{{hc|/etc/php/php.ini|<nowiki>
 +
extension=gd.so
 +
</nowiki>}}
 +
Dokuwiki needs this library for resizing images.
 
=== Apache ===
 
=== Apache ===
  
Firstly, create the file {{ic|/etc/httpd/conf/extra/dokuwiki.conf}} with the following contents:
+
The package should add the file {{ic|/etc/httpd/conf/extra/dokuwiki.conf}} with the following contents:
  
 
{{bc|
 
{{bc|
Line 39: Line 49:
 
     order allow,deny
 
     order allow,deny
 
     allow from all
 
     allow from all
     php_admin_value open_basedir "/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/webapps/dokuwiki/:/var/lib/dokuwiki/"
+
     php_admin_value open_basedir "/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/webapps/dokuwiki/:/var/lib/dokuwiki/"
 
</Directory>
 
</Directory>
 +
}}
 +
 +
If you are running [https://httpd.apache.org/docs/2.4/upgrading.html Apache 2.4 or newer], you will have to change the following lines:
 +
{{bc|
 +
    order allow,deny
 +
    allow from all
 +
}}
 +
to read:
 +
{{bc|
 +
    Require all granted
 
}}
 
}}
  
Line 55: Line 75:
 
Then finish the installation by running the ''dokuwiki/install.php'' script in your browser.
 
Then finish the installation by running the ''dokuwiki/install.php'' script in your browser.
  
=== lighttpd Specific Configuration ===
+
=== lighttpd ===
  
 
Edit the {{ic|/etc/lighttpd/lighttpd.conf}} file as per the [http://www.dokuwiki.org/install:lighttpd dokuwiki instructions] (might contain updated information).
 
Edit the {{ic|/etc/lighttpd/lighttpd.conf}} file as per the [http://www.dokuwiki.org/install:lighttpd dokuwiki instructions] (might contain updated information).
 +
 +
Make sure the modules {{ic|mod_access}} and {{ic|mod_alias}} are loaded. If not, load them by adding the following to {{ic|/etc/lighttpd/lighttpd.conf}}:
 +
{{bc|1=
 +
server.modules += ("mod_access")
 +
server.modules += ("mod_alias")
 +
}}
 +
{{ic|mod_access}} provides the {{ic|url.access-deny}} command, which we are using from this point.
  
 
Under the line:
 
Under the line:
Line 77: Line 104:
  
 
# make sure those are always served through fastcgi and never as static files
 
# make sure those are always served through fastcgi and never as static files
# deny access completly to these
+
# deny access completly to these<nowiki>
$HTTP["url"] =~ "/\.ht" { url.access-deny = ( "" ) }
+
$HTTP["url"] =~ "/(\.|_)ht" { url.access-deny = ( "" ) }
$HTTP["url"] =~ "/_ht" { url.access-deny = ( "" ) }
+
$HTTP["url"] =~ "^" + var.dokudir + "/(bin|data|inc|conf)/"  { url.access-deny = ( "" ) }</nowiki>
$HTTP["url"] =~ "^" + var.dokudir + "/bin/"  { url.access-deny = ( "" ) }
 
$HTTP["url"] =~ "^" + var.dokudir + "/data/" { url.access-deny = ( "" ) }
 
$HTTP["url"] =~ "^" + var.dokudir + "/inc/"  { url.access-deny = ( "" ) }
 
$HTTP["url"] =~ "^" + var.dokudir + "/conf/" { url.access-deny = ( "" ) }
 
 
}}
 
}}
  
Line 93: Line 116:
 
}}
 
}}
  
Then, adjust the {{ic|open_basedir}} in {{ic|/etc/php/php.ini}} to include the dokuwiki directories (php forbids following symbolic links outside of the allowed scope):
+
Restart lighttpd:
 +
  # systemctl restart lighttpd
  
{{hc|/etc/php/php.ini|<nowiki>
+
=== nginx ===
open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/webapps/dokuwiki/:/var/lib/dokuwiki/
+
Ensure that {{Pkg|php-fpm}} is installed and [[start]]ed.
 +
 
 +
Add the following server block, but change the server name to your own and comment out the install.php block until you're done installing DokuWiki. This block assumes you use TLS. [https://www.dokuwiki.org/install:nginx]
 +
{{hc|/etc/nginx/nginx.conf|<nowiki>
 +
    server {
 +
        listen 443 ssl http2;
 +
        listen [::]:443 ssl http2;
 +
        server_name wiki.example.com;
 +
       
 +
        root /usr/share/webapps/dokuwiki;
 +
        index doku.php;
 +
 
 +
        #Remember to comment the below out when you're installing DokuWiki, and uncomment it when you're done.
 +
        location ~ /(data/|conf/|bin/|inc/|install.php) { deny all; } # secure Dokuwiki
 +
 
 +
        location ~^/\.ht { deny all; } # also secure the Apache .htaccess files
 +
        location @dokuwiki {
 +
            #rewrites "doku.php/" out of the URLs if you set the userewrite setting to .htaccess in dokuwiki config page
 +
            rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
 +
            rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
 +
            rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
 +
            rewrite ^/(.*) /doku.php?id=$1&$args last;
 +
        }
 +
 
 +
        location / { try_files $uri $uri/ @dokuwiki; }
 +
        location ~ \.php$ {
 +
            try_files $uri =404;
 +
            fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
 +
            fastcgi_index index.php;
 +
            include fastcgi.conf;
 +
        }
 +
 
 +
    }
 
</nowiki>}}
 
</nowiki>}}
  
Restart lighttp:
+
Restart nginx
   # systemctl restart lighttpd
+
   # systemctl restart nginx
 +
 
 +
=== Enable upload and displaying of SVG files ===
 +
DokuWiki supports SVG files but has them disabled by default.
 +
 
 +
If you wish to enable them, create the following file:
 +
 
 +
{{hc|/etc/webapps/dokuwiki/mime.local.conf|
 +
svg image/svg+xml
 +
}}
 +
This has security implications - [https://github.com/splitbrain/dokuwiki/issues/1045#issuecomment-90226230 see here]
 +
 
 +
== Post installation ==
 +
 
 +
=== Cleaning up ===
 +
 
 +
'''After configuring the server either remove the install.php file or make sure it is made inaccessible in your webserver configuration!'''
 +
  # rm /usr/share/webapps/dokuwiki/install.php
  
== Post Installation ==
+
=== Installing plugins ===
=== Cleaning Up ===
 
'''After configuring the server remove the install.php file!'''
 
  # rm /srv/http/dokuwiki/install.php
 
  
=== Installing Plugins ===
 
 
Many community created plugins can be found [http://www.dokuwiki.org/plugins here]
 
Many community created plugins can be found [http://www.dokuwiki.org/plugins here]
  
They can be added through the web interface (as well as updated) through the Admin menu. Some plugins cannot be downloaded, if they go over ssl (e.g. git). Uncomment following line in {{ic|/etc/php/php.ini}}:
+
They can be added through the web interface (as well as updated) through the Admin menu. Some plugins cannot be downloaded, if they go over ssl (e.g. git).
{{bc|1=  
+
 
extension=openssl.so
+
=== Backing up ===
}}
 
  
=== Backing Up ===
+
It is very trivial to backup DokuWiki, since there is no database. All pages are in plain text, and require only a simple tar, or [[rsync]].  
It is very trivial to backup DokuWiki, since there is no database. All pages are in plain text, and require only a simple tar, or rsync.  
 
  
A quick breakdown of the directories of interest in the current (2008-05-05) version:
+
A quick breakdown of the directories of interest in the current (2015-08-10a) version:
 
   /dokuwiki/data/  =>  All User Created Data
 
   /dokuwiki/data/  =>  All User Created Data
   /dokuwiki/lib/plugins/  =>  All User Added Plugins
+
   /dokuwiki/conf/  =>  Configuration settings
 +
 
 +
This may change in future releases, please consult the [https://www.dokuwiki.org/faq:backup DokuWiki Backup FAQ] for verification.
  
== Further Reading ==
+
== Further reading ==
  
 
The [http://www.dokuwiki.org/ DokuWiki main site] has all of the information and help that you could possibly need.
 
The [http://www.dokuwiki.org/ DokuWiki main site] has all of the information and help that you could possibly need.
 
== See Also ==
 
[http://wiki.gotux.net/config:dokuwiki DokuWiki HowTo Install and Upgrade]
 

Latest revision as of 12:52, 20 September 2017

"DokuWiki is a standards-compliant, simple-to-use wiki which allows users to create rich documentation repositories. It provides an environment for individuals, teams and companies to create and collaborate using a simple yet powerful syntax that ensures data files remain structured and readable outside the wiki."

"Unlimited page revisions allows restoration to any earlier page version, and with data stored in plain text files, no database is required. A powerful plugin architecture allows for extension and enhancement of the core system. See the features section for a full description of what DokuWiki has to offer."[1]

In other words, DokuWiki is a wiki written in PHP and requires no database.

Initial notes

DokuWiki should work on any web server which supports PHP 5.6 or later. As the requirements may change over time, you should consult the requirements page for DokuWiki for additional details.

It is strongly recommend to read through the appropriate sections of DokuWiki's security page for your web server. Most popular web servers are covered but there are generic instructions as well.

The package in [community] unpacks DokuWiki at /usr/share/webapps/dokuwiki with the configuration files in /etc/webapps/dokuwiki and the data files in /var/lib/dokuwiki/data. It also changes the ownership of the relevant files to the "http" user. This should work fine for most popular web servers as packaged for Arch.

Installation

  1. Install your web server of choice (e.g. Apache, nginx or lighttpd) and configure it for PHP. As mentioned above, DokuWiki has no need for a database server so you may be able to skip those steps when setting up your web server.
  2. Install dokuwiki from [community] with pacman.
  3. Configure web server for dokuwiki (see section below)
  4. With your web browser of choice, open http://<your-server>/dokuwiki/install.php and continue the installation from there. For nginx the URL is http://<your-server>/install.php.

Alternatively, if you would like to install from tarball, you can read from http://www.dokuwiki.org/Install. Generally the procedure is the same as above. Instead of using pacman, you will need to download the tarball, unpack it to your server's document root (e.g. /srv/http/dokuwiki), and chown to the appropriate user (e.g. "http").

Configuration

If you are using lighttpd or nginx and your PHP version is lower than 7, you need to adjust the open_basedir in /etc/php/php.ini to include the dokuwiki directories (php forbids following symbolic links outside of the allowed scope):

/etc/php/php.ini
open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/webapps/dokuwiki/:/var/lib/dokuwiki/

Also uncomment the following line.

/etc/php/php.ini
extension=gd.so

Dokuwiki needs this library for resizing images.

Apache

The package should add the file /etc/httpd/conf/extra/dokuwiki.conf with the following contents:

Alias /dokuwiki /usr/share/webapps/dokuwiki
<Directory /usr/share/webapps/dokuwiki/>
    Options +FollowSymLinks
    AllowOverride All
    order allow,deny
    allow from all
    php_admin_value open_basedir "/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/webapps/dokuwiki/:/var/lib/dokuwiki/"
</Directory>

If you are running Apache 2.4 or newer, you will have to change the following lines:

    order allow,deny
    allow from all

to read:

    Require all granted

Include the newly created file in the Apache configuration by placing the following line at the end of /etc/httpd/conf/httpd.conf:

Include conf/extra/dokuwiki.conf

Make sure the folders /etc/webapps/dokuwiki and /var/lib/dokuwiki are owned by user and group "http". You may relocate these directories if you like as long as you update the references in /etc/httpd/conf/extra/dokuwiki.conf respectively.

Afterwards restart Apache:

 # systemctl restart httpd.service

Then finish the installation by running the dokuwiki/install.php script in your browser.

lighttpd

Edit the /etc/lighttpd/lighttpd.conf file as per the dokuwiki instructions (might contain updated information).

Make sure the modules mod_access and mod_alias are loaded. If not, load them by adding the following to /etc/lighttpd/lighttpd.conf:

server.modules += ("mod_access")
server.modules += ("mod_alias")

mod_access provides the url.access-deny command, which we are using from this point.

Under the line:

$HTTP["url"] =~ "\.pdf$" {
  server.range-requests = "disable"
}

add this:

# subdir of dokuwiki
# comprised of the subdir of the root dir where dokuwiki is installed
# in this case the root dir is the basedir plus /htdocs/
# Note: be careful with trailing slashes when uniting strings.
# all content on this example server is served from htdocs/ up.
#var.dokudir = var.basedir + "/dokuwiki"
var.dokudir = server.document-root + "/dokuwiki"

# make sure those are always served through fastcgi and never as static files
# deny access completly to these
$HTTP["url"] =~ "/(\.|_)ht" { url.access-deny = ( "" ) }
$HTTP["url"] =~ "^" + var.dokudir + "/(bin|data|inc|conf)/"  { url.access-deny = ( "" ) }

These entries give some basic security to DokuWiki. lighttpd does not use .htaccess files like Apache. You CAN install with out this, but I would NEVER recommend it.

Add alias somewhere in lighttpd or fastcgi conf file:

alias.url += ("/dokuwiki" => "/usr/share/webapps/dokuwiki/")

Restart lighttpd:

 # systemctl restart lighttpd

nginx

Ensure that php-fpm is installed and started.

Add the following server block, but change the server name to your own and comment out the install.php block until you're done installing DokuWiki. This block assumes you use TLS. [2]

/etc/nginx/nginx.conf
    server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        server_name wiki.example.com;
         
        root /usr/share/webapps/dokuwiki;
        index doku.php;

        #Remember to comment the below out when you're installing DokuWiki, and uncomment it when you're done.
        location ~ /(data/|conf/|bin/|inc/|install.php) { deny all; } # secure Dokuwiki

        location ~^/\.ht { deny all; } # also secure the Apache .htaccess files
        location @dokuwiki {
            #rewrites "doku.php/" out of the URLs if you set the userewrite setting to .htaccess in dokuwiki config page
            rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
            rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
            rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
            rewrite ^/(.*) /doku.php?id=$1&$args last;
        }

        location / { try_files $uri $uri/ @dokuwiki; }
        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
        }

    }

Restart nginx

 # systemctl restart nginx

Enable upload and displaying of SVG files

DokuWiki supports SVG files but has them disabled by default.

If you wish to enable them, create the following file:

/etc/webapps/dokuwiki/mime.local.conf
svg image/svg+xml

This has security implications - see here

Post installation

Cleaning up

After configuring the server either remove the install.php file or make sure it is made inaccessible in your webserver configuration!

 # rm /usr/share/webapps/dokuwiki/install.php

Installing plugins

Many community created plugins can be found here

They can be added through the web interface (as well as updated) through the Admin menu. Some plugins cannot be downloaded, if they go over ssl (e.g. git).

Backing up

It is very trivial to backup DokuWiki, since there is no database. All pages are in plain text, and require only a simple tar, or rsync.

A quick breakdown of the directories of interest in the current (2015-08-10a) version:

 /dokuwiki/data/  =>  All User Created Data
 /dokuwiki/conf/  =>  Configuration settings

This may change in future releases, please consult the DokuWiki Backup FAQ for verification.

Further reading

The DokuWiki main site has all of the information and help that you could possibly need.