跳转至内容

DokuWiki

来自 ArchWiki

来自其 网站

DokuWiki 是一款易于使用且高度通用的开源 wiki 软件,无需数据库。它以其简洁易读的语法深受用户喜爱。易于维护、备份和集成,使其成为管理员的最爱。内置的访问控制和身份验证连接器使 DokuWiki 在企业环境中特别有用,其充满活力的社区贡献的大量插件支持广泛的用例,超越了传统的 wiki。

有关详细的 功能 列表,请参阅上游。

DokuWiki 应该可以在任何支持 PHP 的 Web 服务器上运行。由于要求可能会随时间而变化,您应该查阅 DokuWiki 的 要求页面 以获取更多详细信息。

强烈建议仔细阅读 DokuWiki 安全页面 中与您的 Web 服务器相关的部分。大多数流行的 Web 服务器都有介绍,但也提供了一些通用说明。

安装

位于 官方存储库 中的软件包会将 DokuWiki 解压到 /usr/share/webapps/dokuwiki,配置文件位于 /etc/webapps/dokuwiki,数据文件位于 /var/lib/dokuwiki/data。它还将相关文件的所有权更改为 "http" 用户。这对于 Arch 打包的绝大多数流行 Web 服务器来说应该效果良好。

  1. 安装您选择的 Web 服务器(例如 Apache HTTP Servernginxlighttpd)并对其进行 PHP 配置。如上所述,DokuWiki 不需要数据库服务器,因此您可以在设置 Web 服务器时跳过这些步骤。
  2. 安装 dokuwiki 软件包。
  3. 为 dokuwiki 配置 Web 服务器(参见下文)
  4. 使用您选择的 Web 浏览器,打开 http://<your-server>/dokuwiki/install.php 并从那里继续安装。对于 nginx,URL 是 http://<your-server>/install.php。

或者,如果您想从 tarball 安装,可以从 https://www.dokuwiki.org/Install 阅读。通常过程与上面相同。您将需要 下载 tarball,将其解压到服务器的文档根目录(例如 /srv/http/dokuwiki),并更改为适当的用户(例如 "http"),而不是使用 pacman。

配置

如果您使用 PHP 的 open_basedir,则需要包含 dokuwiki 目录 /etc/webapps/dokuwiki//var/lib/dokuwiki/。例如

/etc/php/php.ini
open_basedir = <other paths>:/etc/webapps/dokuwiki/:/var/lib/dokuwiki/

还要取消注释以下行。

/etc/php/php.ini
extension=gd

Dokuwiki 需要此库来调整图像大小。

然后检查您是否安装了 php-gd 并重启 php-fpm.service

Apache

软件包应添加文件 /etc/httpd/conf/extra/dokuwiki.conf,其内容如下

/etc/httpd/conf/extra/dokuwiki.conf
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>

如果您正在运行 Apache 2.4 或更高版本,您将需要更改以下行

/etc/httpd/conf/extra/dokuwiki.conf
    order allow,deny
    allow from all

改为

/etc/httpd/conf/extra/dokuwiki.conf
    Require all granted

通过在 /etc/httpd/conf/httpd.conf 的末尾添加以下行来包含新创建的文件

/etc/httpd/conf/httpd.conf
Include conf/extra/dokuwiki.conf

确保 /etc/webapps/dokuwiki/var/lib/dokuwiki 文件夹的所有者是 "http" 用户和组。您可以自行移动这些目录,但必须相应地更新 /etc/httpd/conf/extra/dokuwiki.conf 中的引用。您应该保留对 /var/lib/dokuwiki/ 的引用,以便 DokuWiki 找到插件和模板文件夹。

然后 重启 Apache。

然后通过在浏览器中运行 dokuwiki/install.php 脚本来完成安装。

lighttpd

根据 dokuwiki 说明(可能包含更新信息)编辑 /etc/lighttpd/lighttpd.conf 文件。

确保加载了 mod_accessmod_alias 模块。如果没有,请通过在 /etc/lighttpd/lighttpd.conf 中添加以下内容来加载它们

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

mod_access 提供了 url.access-deny 命令,我们从这里开始使用它。

在以下行下方

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

添加此内容

# 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 = ( "" ) }

这些条目为 DokuWiki 提供了一些基本安全性。 lighttpd 不像 Apache 那样使用 .htaccess 文件。您可以不配置这些,但我绝不推荐。

在 lighttpd 或 fastcgi 配置文件中添加别名

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

重启 lighttpd。

nginx

确保已安装并 启动 php-fpm

添加以下服务器块,但将服务器名称更改为您自己的,并在完成 DokuWiki 安装之前注释掉 install.php 块。此块假定您使用 TLS。[1]

/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 are installing DokuWiki, and uncomment it when you are 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-fpm7/php-fpm.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
        }

    }

重启 nginx。

启用 SVG 文件上传和显示

DokuWiki 支持 SVG 文件,但默认情况下禁用它们。

如果您希望启用它们,请创建以下文件

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

这具有安全风险 - 请参见此处

安装后

清理

配置完服务器后,请删除 install.php 文件,或确保在 Web 服务器配置中将其设为不可访问!

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

安装插件

您可以在 此处找到许多社区创建的插件

它们可以通过 Web 界面(以及更新)通过“管理”菜单添加。一些插件无法下载,如果它们通过 SSL(例如 git)。

备份

备份 DokuWiki 非常简单,因为它没有数据库。所有页面都是纯文本,只需要一个简单的 tar 或 rsync

当前(20180422_a-1)版本中相关目录的简要说明

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

这可能会在未来的版本中更改,请查阅 DokuWiki 备份 FAQ 进行验证。

进一步阅读

您可以在 DokuWiki 主网站上找到您可能需要的所有信息和帮助。