如何在Debian 9上安装Dokuwiki
杨和超
・7 分钟阅读
使用不同的系统?
dokuWiki是用PHP编写的开放源码wiki程序,不需要数据库,它将数据存储在文本文件中,DokuWiki源代码公共托管在gitHub ,本指南将向你展示,如何在新的Debian9实例上安装DokuWiki。
要求
确保服务器满足下列要求。
- Nginx
- PHP版本5.6或更高版本,强烈推荐更高版本,(本指南将使用PHP 7.0 )
查看Debian版本。
lsb_release -ds
# Debian GNU/Linux 9.4 (stretch)
确保你的系统是最新的。
apt update && apt upgrade -y
安装必要的软件包。
apt install -y apt-transport-https sudo curl wget dirmngr sudo
使用sudo
访问创建一个新的non-root
用户帐户,并且切换到它。
adduser johndoe --gecos"John Doe"
usermod -aG sudo johndoe
su - johndoe
注:将johndoe
替换为你的用户名。
设置时区。
timedatectl list-timezones
sudo timedatectl set-timezone Region/City
步骤1安装PHP和PHP扩展
Install PHP 7.0和所需的PHP扩展。
sudo apt install -y php7.0 php7.0-cli php7.0-fpm php7.0-gd php7.0-xml php7.0-zip
检查版本。
php --version
# PHP 7.0.27-0+deb9u1 (cli) (built: Jan 5 2018 13:51:52) ( NTS )
# Copyright (c) 1997-2017 The PHP Group
# Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
# with Zend OPcache v7.0.27-0+deb9u1, Copyright (c) 1999-2017, by Zend Technologies
步骤2-安装并配置Nginx
安装Nginx 。
sudo apt install -y nginx
检查版本。
sudo nginx -v
# nginx version: nginx/1.10.3
配置Nginx 。
sudo vim /etc/nginx/sites-available/dokuwiki.conf
使用以下nginx配置填充文件并保存。
server {
listen [::]:80;
listen 80;
server_name wiki.example.com; # Replace with your hostname
root /var/www/dokuwiki;
index index.html index.htm index.php doku.php;
client_max_body_size 15M;
client_body_buffer_size 128K;
location / {
try_files $uri $uri/ @dokuwiki;
}
location ^~ /conf/ { return 403; }
location ^~ /data/ { return 403; }
location ~ /.ht { deny all; }
location @dokuwiki {
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 last;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
通过将文件链接到sites-enabled
目录来激活新的dokuwiki.conf
配置。
sudo ln -s /etc/nginx/sites-available/dokuwiki.conf /etc/nginx/sites-enabled/
检查配置。
sudo nginx -t
重新加载Nginx 。
sudo systemctl reload nginx.service
步骤3安装DokuWiki
创建文档root目录。
sudo mkdir -p /var/www/dokuwiki
将/var/www/dokuwiki
目录的所有权更改为johndoe
。
sudo chown -R johndoe:johndoe /var/www/dokuwiki
导航到文档root 。
cd/var/www/dokuwiki
最新的DokuWiki稳定版本从dokuWiki下载页面 下载。
wget https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz
解压DokuWiki tar文件。
tar xvf dokuwiki-stable.tgz
rm dokuwiki-stable.tgz
mv dokuwiki-2018-04-22a/* . && mv dokuwiki-2018-04-22a/.* .
rmdir dokuwiki-2018-04-22a/
将/var/www/dokuwiki
目录的所有权更改为www-data
。
sudo chown -R www-data:www-data /var/www/dokuwiki
重新启动php7.0-fpm.service
。
sudo systemctl restart php7.0-fpm.service
在浏览器中打开DokuWiki安装脚本install.php
,并设置DokuWiki ,安装脚本检查所需的PHP函数是否可用,并检查必要的文件权限,它还创建初始管理员帐户和初始ACL策略,要运行安装程序,请打开 http://wiki.example.com/install.php
在浏览器中并按照说明操作。
成功配置后,从DokuWiki root目录中删除install.php
文件。
sudo rm /var/www/dokuwiki/install.php
安装了DokuWiki,你就可以在http://wiki.example.com/访问和编辑wiki了。