Ubuntu 20.04 LTSにDokuWikiをインストールする方法

Ubuntu/Debian

DokuWikiは、PHPで記述された、無料のオープンソースで最も用途の広いwikiアプリケーションです。シンプルなファイル形式を使用してデータを保存するシンプルで軽量なため、データベースは必要ありません。クリーンで読みやすい構文で知られており、多くの高度な機能を使用して簡単にスケーリングおよび最適化できます。サーバーにコンテンツをアップロードするだけで、個人またはビジネスのWebサイトを作成できます。 WYSIWYGサポート、SEO対応の組み込みアクセス制御、認証コネクタ、柔軟なCSSフレームワークなど、豊富な機能セットが付属しています。

このチュートリアルでは、Ubuntu20.04にApacheとLetsencryptSSL証明書を使用してDokuWikiをインストールする方法を示します。

前提条件

  • Ubuntu20.04を実行しているサーバー。
  • サーバーが指す有効なドメイン名。
  • ルートパスワードはサーバーで構成されます。

システムパッケージを更新する

開始する前に、システムパッケージを最新バージョンに更新することをお勧めします。次のコマンドで実行できます。

apt-get update -y
 apt-get upgrade -y

システムが更新されたら、システムを再起動して変更を実装します。

ApacheとPHPをインストールする

DokuWikiはPHPで記述されており、Webサーバー上で実行されます。そのため、Apache Webサーバー、PHP、およびその他のPHPライブラリをシステムにインストールする必要があります。次のコマンドを実行して、それらすべてをインストールできます。

apt-get install apache2 php php-gd php-xml php-json -y

すべてのパッケージがインストールされたら、Apacheサービスを開始し、次のコマンドを使用して起動時に開始できるようにします。

systemctl start apache2
 systemctl enable apache2

完了したら、次のステップに進むことができます。

DokuWikiをダウンロードする

まず、DokuWikiの公式ダウンロードページに移動し、次のコマンドを使用してDokuWikiの最新バージョンをダウンロードします。

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

ダウンロードが完了したら、Apache Webルートディレクトリ内にDokuWikiディレクトリを作成し、DokuWikiを抽出します。

mkdir /var/www/html/dokuwiki
 tar -xvzf dokuwiki-rc.tgz -C /var/www/html/dokuwiki/ --strip-components=1

次に、次のコマンドを使用して、サンプルの.htaccessファイルをコピーします。

cp /var/www/html/dokuwiki/.htaccess{.dist,}

次に、dokuwikiの所有権をwww-dataに変更します。

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

終了したら、次のステップに進むことができます。

DokuWiki用にApacheを構成する

次に、DokuWikiWebサイトにサービスを提供するApache仮想ホスト構成ファイルを作成します。

nano /etc/apache2/sites-available/dokuwiki.conf

次の行を追加します。

<VirtualHost *:80>
        ServerName    dokuwiki.linuxbuz.com      
        DocumentRoot  /var/www/html/dokuwiki

        <Directory ~ "/var/www/html/dokuwiki/(bin/|conf/|data/|inc/)">
            <IfModule mod_authz_core.c>
                AllowOverride All
                Require all denied
            </IfModule>
            <IfModule !mod_authz_core.c>
                Order allow,deny
                Deny from all
            </IfModule>
        </Directory>

        ErrorLog   /var/log/apache2/dokuwiki_error.log
        CustomLog  /var/log/apache2/dokuwiki_access.log combined
</VirtualHost>

終了したら、ファイルを保存して閉じます。次に、DokuWikiサイトを有効にし、次のコマンドを使用してApacheサービスをリロードします。

a2ensite dokuwiki.conf
 systemctl reload apache2

この時点で、ApacheWebサーバーはDokuWikiサイトにサービスを提供するように構成されています。これで、Let’s EncryptSSLをWebサイトにインストールすることができます。

Let’s EncryptSSLでDokuWikiを保護する

まず、システムにCertbotクライアントをインストールする必要があります。 Certbotは、EFF、Mozillaなどによって起動されたオープン認証局であるLet’s Encryptから証明書をフェッチし、それをWebサーバーに展開する使いやすいクライアントです。 Certbot Let’s Encryptクライアントを使用すると、ドメインのSSL証明書を簡単にダウンロード、インストール、更新できます。

次のコマンドでCertbotをインストールできます。

apt-get install certbot python3-certbot-apache -y

Certbotクライアントが正常にインストールされたら、次のコマンドを実行して、WebサイトにLet’s EncryptSSLをインストールします。

certbot --apache -d dokuwiki.linuxbuz.com

以下に示すように、有効な電子メールを提供し、利用規約に同意するように求められます。

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): hitjethva@gmail.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

Obtaining a new certificate
Performing the following challenges:
http-01 challenge for dokuwiki.linuxbuz.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/dokuwiki-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/dokuwiki-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/dokuwiki-le-ssl.conf

次に、次の出力に示すように、HTTPトラフィックをHTTPSにリダイレクトするか、すべてのトラフィックをセキュアなHTTPSアクセスにリダイレクトするようにNginxを構成するかを選択します。

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

2と入力し、Enterキーを押してプロセスを開始します。インストールが完了すると、次の出力が表示されます。

Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/dokuwiki.conf to ssl vhost in /etc/apache2/sites-available/dokuwiki-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://dokuwiki.linuxbuz.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=dokuwiki.linuxbuz.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/dokuwiki.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/dokuwiki.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-09-05. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot 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サイトはLet’s EncryptSSLで保護されています。これで、HTTPSプロトコルを使用してサイトに安全にアクセスできます。

DokuWikiにアクセスする

次に、Webブラウザーを開き、URLhttps ://dokuwiki.linuxbuz.com/install.phpを入力します。 DokuWikiのインストール画面が表示されます。

DokuWikiインストーラー

 

ライセンスを選択

ウィキ名、管理者ユーザー名、パスワード、電子メールを入力し、ポリシーを選択して、[保存]ボタンをクリックします。次のページにリダイレクトされます。

完成した構成

younewDokuWikiクリックします。次の画面が表示されます。

DokuWikiウェルカムページ

ログインボタンをクリックします。以下に示すように、DokuWikiのログイン画面にリダイレクトされます。

DokuWikiログイン

あなたの管理者のユーザー名、パスワードを入力してログインボタンをクリックします。次の画面にDokuWikiダッシュボードが表示されます。

DokuWiki管理ダッシュボード

セットアップSSL証明書の自動更新を暗号化しましょう

デフォルトでは、Let’sEncrypt証明書は90日間有効です。したがって、SSL証明書を自動更新するためにcronジョブを設定する必要があります。毎週または毎日実行するcronジョブを作成しても安全です。

SSL証明書を手動で更新する場合は、次のコマンドを実行します。

certbot renew --dry-run

次のファイルを編集することにより、毎日午前10時にSSL証明書を自動更新するようにcronジョブを設定できます。

crontab -e

次の行を追加します。

00 10 * * *   root /usr/bin/certbot renew >/dev/null 2>&1

終了したら、ファイルを保存して閉じます。

結論

おめでとう!これで、DokuWikiが正常にインストールされ、Ubuntu20.04でLet’sEncryptSSLを使用して保護されました。テーマ、プラグイン、テンプレートを使用してDokuWikiを拡張することもできます。ご不明な点がございましたら、お気軽にお問い合わせください。

Source

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です