在 Ubuntu 上使用 DokuWiki 构建你自己的 wiki
DokuWiki 维基
我们在使用 [DokuWiki](https://github.com/splitbrain/dokuwiki)，它是一个真棒的工具。我们团队有一个内部知识库，我们使用 DokuWiki 存储我们的所有评论、教程等。它很简单，并且易于安装和使用。在这篇文章中，我们将展示如何在 Ubuntu 16.04 服务器上安装 DokuWiki。


![](/data/attachment/album/201702/06/090856n10meuei055x5wh0.jpg)


### 需求


DokuWiki 不需要太多依赖，因为它不需要数据库。这里是 DokuWiki 的要求：


* PHP 5.3.4 或更高版本（建议使用 PHP 7+）
* 一台 web 服务器（Apache/Nginx/任何其他）
* 一台 VPS。[买一台便宜的托管 VPS](http://click.aliyun.com/m/7604/)，那么你就不必这样做了。你只需与支持团队联系，他们将会为您安装。


### 指导


在你开始之前，你应该升级你的系统。运行下面的命令：



```
sudo apt-get update && sudo apt-get upgrade

```

### 安装 Apache


我们需要一台用于我们 wiki 的 web 服务器。我们在本教程中使用 Apache，但你也可以使用 Nginx 或任何其他 web 服务器。用下面的命令安装apache：



```
apt-get install apache2

```

### 安装 PHP7 和模块


接下来，如果你还没有安装 PHP，你应该先安装 PHP。在本教程中，我们使用 PHP7。所以请使用下面的命令安装 PHP7 和一些其他 PHP 模块：



```
apt-get install php7.0-fpm php7.0-cli php-apcu php7.0-gd php7.0-xml php7.0-curl php7.0-json php7.0-mcrypt php7.0-cgi php7.0 libapache2-mod-php7.0

```

### 下载安装 DokuWiki


下面就来到主要部分了 - 实际安装 DokuWiki。


首先，为你的 DokuWiki 创建一个目录：



```
mkdir -p /var/www/thrwiki

```

进入你刚才创建的目录：



```
cd /var/www/thrwiki

```

运行下面的命令来下载最新（稳定）的 DokuWiki：



```
wget http://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz

```

解压 .tgz 文件：



```
tar xvf dokuwiki-stable.tgz

```

更改文件/文件夹权限：



```
www-data:www-data -R /var/www/thrwiki
chmod -R 707 /var/www/thrwiki

```

### 为 DokuWiki 配置 Apache


为你的 DokuWiki 创建一个 .conf 文件（我们把它命名为 `thrwiki.conf`，但是你可以把它命名成任何你想要的），并用你喜欢的文本编辑器打开。我们使用 nano：



```
touch /etc/apache2/sites-available/thrwiki.conf
ln -s /etc/apache2/sites-available/thrwiki.conf /etc/apache2/sites-enabled/thrwiki.conf
nano /etc/apache2/sites-available/thrwiki.conf

```

下面是 thrwiki.conf 中的内容：



```
<VirtualHost yourServerIP:80>
  ServerAdmin wikiadmin@thishosting.rocks
  DocumentRoot /var/www/thrwiki/
  ServerName wiki.thishosting.rocks
  ServerAlias www.wiki.thishosting.rocks
  <Directory /var/www/thrwiki/>
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
  ErrorLog /var/log/apache2/wiki.thishosting.rocks-error_log
  CustomLog /var/log/apache2/wiki.thishosting.rocks-access_log common
</VirtualHost>

```

编辑与你服务器相关的行。将 `wikiadmin@thishosting.rocks`、`wiki.thishosting.rocks` 替换成你自己的数据，重启 apache 使更改生效：



```
systemctl restart apache2.service

```

就是这样了。现在已经配置完成了。现在你可以继续通过前端页面 http://wiki.thishosting.rocks/install.php 安装配置 DokuWiki 了。安装完成后，你可以用下面的命令删除 install.php：



```
rm -f /var/www/html/thrwiki/install.php

```

如果你需要任何帮助，请随意留下评论。




---


via: <https://thishosting.rocks/build-your-own-wiki-on-ubuntu-with-dokuwiki/>


作者：[thishostrocks.com](https://twitter.com/thishostrocks) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
We use [DokuWiki](https://github.com/splitbrain/dokuwiki) and it’s awesome. Our team has an internal knowledgebase and we use DokuWiki to store all our reviews, tutorials etc. It’s simple, easy to install and easy to use. Most importantly, it’s not resource-heavy. In this post, we’re going to show you how to install DokuWiki on an Ubuntu 16.04 server.


## Requirements

DokuWiki doesn’t need much since it doesn’t need a database. Here are the requirements of DokuWiki:

- PHP 5.3.4 or newer (PHP 7+ recommended)
- A web server (Apache/Nginx/Any other)
- A VPS.
[Get a cheap managed VPS](https://thishosting.rocks/best-cheap-managed-vps/)and you won’t have to do any of this. Just contact the support team and they will install it for you.

## Instructions

Before you do anything, you should upgrade your system. Run the following command:

sudo apt-get update && sudo apt-get upgrade

### Install Apache

We are going to need a web server for our wiki. We’ll be using Apache for our tutorial, but you can also use Nginx or any other web server. Install apache with:

apt-get install apache2

### Install PHP7 and modules

Next, you should install PHP if you don’t already have it installed. In this tutorial, we’ll be using PHP7. So, install PHP7 and a few other PHP modules with the following command:

apt-get install php7.0-fpm php7.0-cli php-apcu php7.0-gd php7.0-xml php7.0-curl php7.0-json php7.0-mcrypt php7.0-cgi php7.0 libapache2-mod-php7.0

### Download and install DokuWiki

Here comes the main part – the actual installation of DokuWiki.

First, create a directory for your DokuWiki:

mkdir -p /var/www/thrwiki

Navigate to the directory you just created:

cd /var/www/thrwiki

Run the following command to download the latest (stable) version of DokuWiki:

wget http://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz

Unpack the .tgz file:

tar xvf dokuwiki-stable.tgz

Change some file/folder permissions:

www-data:www-data -R /var/www/thrwiki chmod -R 707 /var/www/thrwiki

## Configure Apache for DokuWiki

Create a .conf file for your DokuWiki (we’ll name it thrwiki.conf, but you can name it however you want) and open it with your favorite text editor. We’ll be using nano:

touch /etc/apache2/sites-available/thrwiki.conf ln -s /etc/apache2/sites-available/thrwiki.conf /etc/apache2/sites-enabled/thrwiki.conf nano /etc/apache2/sites-available/thrwiki.conf

<VirtualHost yourServerIP:80> ServerAdmin wikiadmin@thishosting.rocks DocumentRoot /var/www/thrwiki/ ServerName wiki.thishosting.rocks ServerAlias www.wiki.thishosting.rocks <Directory /var/www/thrwiki/> Options FollowSymLinks AllowOverride All Order allow,deny allow from all </Directory> ErrorLog /var/log/apache2/wiki.thishosting.rocks-error_log CustomLog /var/log/apache2/wiki.thishosting.rocks-access_log common </VirtualHost>

systemctl restart apache2.service

rm -f /var/www/html/thrwiki/install.php

Feel free to leave a comment below if you need any help.

## 5 thoughts on “Build your own wiki on Ubuntu with DokuWiki”

I guess to change folder owner and group you should write:




chown www-data:www-data -R /var/www/thrwiki

Also, I use a Docker image to deploy very fast a DokuWiki.

can you explain in detail how you build and deploy a docker image with dokuwiki please?

I’m new to servers and linux, and you say: “Edit the lines to correspond with your server setup. Replace wikiadmin@thishosting.rocks, wiki.thishosting.rocks etc with your own data” how do I get my own information for my own server? I have a server that I program with, not sure if that’s the same thing, but I’m not sure that I have an address that corresponds with it? I hope you can make sense of my question. Thanks.

You’ll first need to own a domain name. You can get one from Namecheap https://thishosting.rocks/neamcheap-review-cheap-domains-cool-names/

After that, you’ll need to configure your domain name’s DNS settings to correspond with your server’s IP.

And finally you’ll need to replace each email and domain mentioned in this post with your own domain name.

For install PHP 7.4

sudo apt update

sudo apt install php php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath

BR