How to install and configure DokuWiki with Nginx on CentOS 8

DokuWiki is an easy-to-use and versatile open source wiki program that does not require a database. It is loved by users due to its clean, easy-to-read formula. Ease of maintenance, easy backup, and integration make it an admin’s favorite.

Built-in access control and authentication connectors make DokuWiki extremely useful in an enterprise context and the large number of plugins contributed by its active community allows for a variety of use cases outside of traditional wikis.

This tutorial will show you how to install DokuWiki on a new CentOS 8 server.

DokuWiki requirements

Make sure your server meets the following requirements.

  • Web server software that supports PHP (Apache, NGINX, IIS, Lighttpd, LiteSpeed)
  • PHP version 5.6 or later, newer version is highly recommended.

precondition

  • Server with CentOS 8.
  • Log in as root or a user with sudo privileges

Initial step

Check your CentOS version:

cat /etc/centos-release
# CentOS Linux release 8.0.1905 (Core)

Prepare the server’s timezone, in this example we’ll set the timezone to Asia / Jakarta:

timedatectl list-timezones
sudo timedatectl set-timezone 'Asia/Jakarta'

Update the operating system (software) package. This is an important first step as it ensures that you have the latest updates and security fixes for the default software packages for your operating system:

sudo dnf update -y

Install some basic packages required for basic CentOS management:

sudo dnf install -y curl wget vim git unzip socat bash-completion epel-release

Step 1 – Install PHP and PHP Extensions

Install the required PHP and PHP extensions:

sudo dnf install -y php php-cli php-fpm php-gd php-xml php-zip

To display a bulk PHP module, you can run:

php -m

ctype
curl
exif
fileinfo
. . .
. . .

Check PHP version:

php --version

# PHP 7.2.11-1-(cli) (built: Oct 26 2019 14:14:18) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.3.11-1~deb10u1, Copyright (c) 1999-2018, by Zend Technologies

Initiate and activate PHP-FPM with the command:

sudo systemctl start php-fpm.service
sudo systemctl enable php-fpm.service

Step 2 – Install the Acme.sh Client and Install Let’s Encrypt Certificate (Optional)

Securing your website with HTTPS is very important, and it is a good practice to secure your site traffic. To get an SSL certificate from Let’s Encrypt we will be using the Acme.sh client.

Acme.sh is a pure Unix Shell program to get SSL certificates from Let’s Encrypt without dependencies.

Download and install Acme.sh:

sudo su - root
git clone https://github.com/Neilpang/acme.sh.git
cd acme.sh 
./acme.sh --install --accountemail [email protected]
source ~/.bashrc
cd ~

Check the version of Acme.sh:

acme.sh --version
# v2.8.2

Get certified RSA And the ECC / ECDSA For your domain / hostname:

# RSA 2048
acme.sh --issue --standalone -d example.com --keylength 2048
# ECDSA
acme.sh --issue --standalone -d example.com --keylength ec-256

If you want to create a fake test certificate, you can add a flag --stagingFor the above command.

After executing the above command, Certificates And the Keys It will be in:

  • to me RSA In the manual: /home/username/example.com.
  • to me ECC / ECDSA In the manual: /home/username/example.com_ecc.

To list all certificates, run the command:

acme.sh --list

Create a directory to store your certificates. We will use directories /etc/letsencrypt

mkdir -p /etc/letsecnrypt/example.com
sudo mkdir -p /etc/letsencrypt/example.com_ecc

Install / copy certificate to directory /etc/letsencrypt.

# RSA
acme.sh --install-cert -d example.com --cert-file /etc/letsencrypt/example.com/cert.pem --key-file /etc/letsencrypt/example.com/private.key --fullchain-file /etc/letsencrypt/example.com/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"
# ECC/ECDSA
acme.sh --install-cert -d example.com --ecc --cert-file /etc/letsencrypt/example.com_ecc/cert.pem --key-file /etc/letsencrypt/example.com_ecc/private.key --fullchain-file /etc/letsencrypt/example.com_ecc/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"

All certificates will be renewed automatically every 60 days.

After obtaining the certificate, terminate the root user and revert to the normal user with their rights sudo :

exit

Step 3 – Install and configure Nginx

DokuWiki will run on any web server that supports PHP. For this tutorial, we’ll be using Nginx. If you prefer Apache or another web server, you can use it in place of Nginx.

Download and install NGINX from the default CentOS repositories:

sudo dnf install -y nginx

Check out the NGINX version:

sudo nginx -v
# nginx version: nginx/1.14.2

Next, configure NGINX for the DokuWiki CMS. We will create a server block for DokuWiki and add the following configuration.

sudo nano /etc/nginx/conf.d/dokuwiki.conf

Copy / paste the following Nginx configuration and save it:

server {

    listen [::]:443 ssl;
    listen 443 ssl;
    listen [::]:80;
    listen 80;
    # RSA
    ssl_certificate /etc/letsencrypt/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/example.com/private.key;
    # ECC
    ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/example.com_ecc/private.key;
    server_name wiki.example.com;
    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 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Check NGINX configuration for no syntax errors:

sudo nginx -t

Reload Nginx with the following command

sudo systemctl reload nginx.service

Step 4 – Install DokuWiki

Create a document root directory for DokuWiki

sudo mkdir -p /var/www/dokuwiki

Enter the document’s root directory:

cd /var/www/dokuwiki

Download the latest version of DokuWiki from the DokuWiki download page with the command wget:

sudo wget https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz

The command below will extract the DokuWiki tarball file, delete the dokuwiki-stabil.tgz tar archive and move the extracted file to the document root:

sudo tar xvf dokuwiki-stable.tgz
sudo rm dokuwiki-stable.tgz
sudo mv dokuwiki-2018-04-22b/* . && mv dokuwiki-2018-04-22b/.* .
sudo rmdir dokuwiki-2018-04-22b/

Change ownership of the directory /var/www/dokuwiki Becomewww-data:

sudo chown -R nginx:nginx /var/www/dokuwiki

Then restart php7.3-fpm.service:

sudo systemctl restart php7.3-fpm.service

Step 5 – Install DokuWiki Web Interface

Open a web browser and type the URL http://example.com/install.php. You will be directed to the following page:

Page 1 - DokuWiki Installer

Provide all necessary information such as your superusername, email, and password. Then click the button save. After successful installation, you will see the following page:

Page 2 - Set username and password

Now, click Your new DokuWiki. You will see the following page:

Page 3 - DokuWiki installed successfully

Now, click on the button sign in. You will be directed to the following page:

Page 4 - Dokuwiki login

Now, enter the administrator username and password. Then click the button Record in a. You should see the DokuWiki dashboard on the following page:

Page 5 - Welcome to DokuWiki

After successful configuration, delete the file install.php From a DokuWiki root directory:

sudo rm /var/www/dokuwiki/install.php

Congratulations! You have successfully installed and configured DokuWiki on the CentOS 8 server. Now you can easily create your own wiki using DokuWiki.

.

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *