DokuWiki
来自其网站
- DokuWiki 是一款简单易用且功能丰富的开源 Wiki 软件,无需数据库。它因其简洁易读的语法而深受用户喜爱。易于维护、备份和集成使其成为管理员的最爱。内置的访问控制和身份验证连接器使 DokuWiki 在企业环境中特别有用,其充满活力的社区贡献的大量插件使其应用场景超越了传统的 Wiki。
请访问上游网站查看详细的功能列表。
DokuWiki 应该可以在任何支持 PHP 的 Web 服务器上运行。由于需求可能会随时间变化,您应该查阅 DokuWiki 的需求页面以获取更多详细信息。
强烈建议您阅读 DokuWiki 安全页面中关于您的 Web 服务器的相应章节。其中涵盖了大多数流行的 Web 服务器,但也提供了一般性说明。
安装
在官方仓库中的软件包将 DokuWiki 解压到 /usr/share/webapps/dokuwiki
,配置文件位于 /etc/webapps/dokuwiki
,数据文件位于 /var/lib/dokuwiki/data
。它还将相关文件的所有权更改为 “http” 用户。这应该适用于大多数流行的 Web 服务器,因为它们是为 Arch 打包的。
- 安装您选择的 Web 服务器(例如 Apache HTTP 服务器、nginx 或 lighttpd)并为其配置 PHP。如上所述,DokuWiki 不需要数据库服务器,因此在设置 Web 服务器时,您可以跳过这些步骤。
- 安装 dokuwiki 软件包。
- 为 dokuwiki 配置 Web 服务器(见下节)
- 使用您选择的 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
的末尾,将新创建的文件包含在 Apache 配置中
/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 找到插件和 tpl 文件夹。
之后,重启 Apache。
然后通过在浏览器中运行 dokuwiki/install.php 脚本完成安装。
lighttpd
根据 dokuwiki 说明 编辑 /etc/lighttpd/lighttpd.conf
文件(可能包含更新的信息)。
确保加载了模块 mod_access
和 mod_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
添加以下服务器块,但将服务器名称更改为您自己的名称,并在完成 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 主站点拥有您可能需要的所有信息和帮助。