웹사이트 검색

Ubuntu 22.04|20.04|18.04에 DokuWiki를 설치하는 방법


DokuWiki는 PHP로 작성된 무료 오픈 소스 위키 소프트웨어입니다. DokuWiki는 매우 다재다능하며 일반 텍스트 파일에서 작동하므로 데이터베이스가 필요하지 않습니다. 이는 MediaWiki에서 사용되는 것과 유사한 구문을 가지고 있습니다. 이 가이드에서는 암호화를 위한 Nginx 및 Letsencrypt SSL 인증서를 사용하여 Ubuntu 22.04|20.04|18.04에 DokuWiki를 설치하는 단계를 설명합니다.

DokuWiki 설치 전제조건:

  • 업데이트된 시스템
  • PHP와 php-fpm
  • Nginx 또는 Apache 웹 서버
  • Certbot 인증서 요청을 위한 certbot-auto

모든 소프트웨어 요구 사항이 설치되었는지 확인하는 것부터 시작하겠습니다.

1단계: 시스템 패키지 업데이트

적절한 색인과 모든 소프트웨어 패키지가 업데이트되었는지 확인하십시오.

sudo apt update

시스템을 재부팅한 후 시스템 호스트 이름을 설정하고 PHP 및 모든 필수 모듈 설치를 진행합니다.

sudo hostnamectl set-hostname wiki.example.com

2단계: PHP 및 필수 모듈 설치

이제 DokuWiki에 필요한 PHP와 일부 PHP 모듈을 설치해야 합니다. 모든 것을 설치하려면 다음 명령을 실행하십시오.

sudo apt -y install php php-curl php-apcu php-fpm php-bcmath php-gd php-intl php-pear php-imap php-memcache libapache2-mod-php php-pspell php-tidy php-xmlrpc php-mbstring php-gmp php-json php-xml php-common

시스템의 PHP 버전을 확인하세요.

$ php -v
PHP 8.1.2 (cli) (built: Aug  8 2022 07:28:23) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2, Copyright (c), by Zend Technologies

시스템에 설치된 PHP 확장 목록을 얻으려면 php -m 명령을 사용하세요:

php -m

3단계: Nginx 및 certbot-auto 설치

나중에 DokuWiki 사이트에 대한 인증서를 얻는 데 사용할 nginx 웹 서버와 certbot을 설치해 보겠습니다.

sudo apt update
sudo apt install wget nginx certbot

4단계: DokuWiki 다운로드 및 설치

DokuWiki 버전을 다운로드하기 전에 다운로드 페이지에서 최신 안정 릴리스를 확인하세요.

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

tar를 사용하여 DokuWiki 아카이브 추출

tar xvf dokuwiki-stable.tgz
sudo mv dokuwiki-*/ /var/www/html/dokuwiki

/var/www/html/dokuwiki의 소유권을 www-data 사용자 및 그룹으로 변경합니다.

sudo chown -R www-data:www-data /var/www/html/dokuwiki/

5단계: DokuWiki용 Nginx 프록시 구성

DokuWiki는 http나 https에서 사용할 수 있습니다.

옵션 1: SSL 인증서 없이 Nginx 사용

SSL 연결이 필요하지 않은 경우 https 섹션 없이 Nginx를 구성할 수 있습니다. Dokuwiki 가상호스트 파일을 생성합니다.

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

이 설정을 붙여넣고 수정하세요.

# Dokuwiki Nginx configuration
server {
  listen 80;
  server_name wiki.example.com;
  root /var/www/html/dokuwiki/;

 access_log /var/log/nginx/dokuwiki.access.log;
 error_log /var/log/nginx/dokuwiki.error.log;

 index index.html index.php doku.php;

location / {
 try_files $uri $uri/ @dokuwiki;
 }

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 ~ /(data|conf|bin|inc)/ {
 deny all;
 }

location ~* \.(css|js|gif|jpe?g|png)$ {
 expires 1M;
 add_header Pragma public;
 add_header Cache-Control "public, must-revalidate, proxy-revalidate";
 }

location ~ \.php$ {
 fastcgi_split_path_info ^(.+\.php)(/.+)$;
 fastcgi_pass unix:/var/run/php/php-fpm.sock;
 fastcgi_index index.php;
 include fastcgi_params;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 fastcgi_intercept_errors off;
 fastcgi_buffer_size 16k;
 fastcgi_buffers 4 16k;
 }

location ~ /\.ht {
 deny all;
 }
}

wiki.example.com을 도메인 이름으로 바꾸는 것을 잊지 마세요. 완료되면 Nginx 구성 구문을 테스트합니다.

$ sudo nginx  -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

nginx 서비스 다시 시작

sudo systemctl restart nginx

서비스가 오류 없이 시작되었는지 확인합니다.

$ systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-10-05 18:11:17 EAT; 7s ago
       Docs: man:nginx(8)
    Process: 53704 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 53705 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 53706 (nginx)
      Tasks: 2 (limit: 9460)
     Memory: 2.6M
        CPU: 23ms
     CGroup: /system.slice/nginx.service
             ├─53706 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             └─53707 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

Oct 05 18:11:17 jammy systemd[1]: Starting A high performance web server and a reverse proxy server...
Oct 05 18:11:17 jammy systemd[1]: Started A high performance web server and a reverse proxy server.

브라우저를 열고 http://wiki.example.com/install.php에 액세스하세요.

옵션 2: SSL 인증서 없이 Nginx 사용

certbot-auto가 포트 80에 바인딩되므로 nginx를 중지합니다.

sudo systemctl stop nginx

그런 다음 인증서를 요청하십시오.

export DOMAIN='wiki.example.com'
export EMAIL="[email "
sudo certbot certonly --standalone -d $DOMAIN \
 --preferred-challenges http --agree-tos -n -m $EMAIL \
 --keep-until-expiring

성공하면 certbot이 성공 메시지를 표시합니다.

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for wiki.computingforgeeks.com
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/wiki.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/wiki.example.com/privkey.pem
   Your cert will expire on 2022-01-27. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot-auto
   again. To non-interactively renew *all* of your certificates, run
   "certbot-auto renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Dokuwiki 가상호스트 파일을 생성합니다.

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

다음 내용을 추가하고 사용 사례에 맞게 수정하세요. wiki.example.com을 도메인 이름으로 바꾸세요.

# Dokuwiki Nginx configuration
server {

listen 443 ssl;
 server_name wiki.example.com;
 root /var/www/html/dokuwiki/;

 access_log /var/log/nginx/dokuwiki.access.log;
 error_log /var/log/nginx/dokuwiki.error.log;
 
 ssl on;
 ssl_certificate /etc/letsencrypt/live/wiki.example.com/fullchain.pem;
 ssl_certificate_key /etc/letsencrypt/live/wiki.example.com/privkey.pem;
 ssl_session_timeout 5m;
 ssl_ciphers 'AES128+EECDH:AES128+EDH:!aNULL';
 ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
 ssl_prefer_server_ciphers on;

 index index.html index.php doku.php;

location / {
 try_files $uri $uri/ @dokuwiki;
 }

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 ~ /(data|conf|bin|inc)/ {
 deny all;
 }

location ~* \.(css|js|gif|jpe?g|png)$ {
 expires 1M;
 add_header Pragma public;
 add_header Cache-Control "public, must-revalidate, proxy-revalidate";
 }

location ~ \.php$ {
 fastcgi_split_path_info ^(.+\.php)(/.+)$;
 fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
 fastcgi_index index.php;
 include fastcgi_params;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 fastcgi_intercept_errors off;
 fastcgi_buffer_size 16k;
 fastcgi_buffers 4 16k;
 }

location ~ /\.ht {
 deny all;
 }
}

# Redirect http to https
server { 
 listen 80;
 server_name wiki.example.com;
 add_header Strict-Transport-Security max-age=2592000;
 rewrite ^ https://wiki.example.com$request_uri? permanent;
}

wiki.example.com의 모든 존재를 귀하의 위키 도메인으로 바꾸세요.

nginx 구문을 확인하세요.

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

오류가 없으면 nginx 및 php-fpm을 다시 시작하십시오.

sudo systemctl restart php-fpm nginx

6단계: 웹 인터페이스에서 DokuWiki 구성

https://wiki.mydomain/install.php 링크를 열어 DokuWiki 구성을 시작하면 아래와 같은 설치 페이지가 나타납니다.

관리자 세부정보를 제공하고 초기 ACL 정책에서 다음 중 하나의 정책을 선택합니다.

  • 위키 열기 – 모두에게 공개
  • 공개 위키 – 등록된 사용자가 모두 읽고 업로드하고 편집할 수 있습니다.
  • 비공개 위키 – 등록된 사용자만 접근 가능

사용자가 스스로 등록하도록 허용할지 확인하세요.

완료되면 저장을 클릭하세요. 이제 위키 페이지가 준비되었습니다.

DokuWiki 홈페이지로 이동하려면 '새 DokuWiki' 를 클릭하세요.

8단계: DokuWiki에 사용자 추가하기

'닫힌 위키 | 공개' ACL 정책으로 설정하면 편집할 수 있는 로그인 페이지가 제공됩니다. 시스템에 다른 사용자를 추가하려면 이전에 만든 관리자 계정으로 로그인하세요.

페이지 상단에 있는 “관리자” 아이콘을 클릭하면 관리 페이지로 이동됩니다.

사용자 추가 페이지를 보려면 '사용자 관리자' 를 클릭하세요.

사용자 세부정보를 추가하고 '추가' 버튼을 클릭하세요. 사용자를 추가한 후 '액세스 제어 목록 관리' 페이지에서 ACL을 할당할 수 있습니다.

주어진 권한 중에서 선택하세요.

다음 위키 가이드에서는 기능을 확장하기 위해 DokuWiki에 플러그인을 설치하는 방법을 다룰 것입니다.

  • Chezmoi – 여러 컴퓨터에서 도트파일을 안전하게 관리
  • 터미널에 wtfutil 개인 정보 대시보드 설치

관련기사: