KUSANAGIでWordPressサイトをSSL化する方法

KUSANAGIでWordPressサイトをSSL化する方法について紹介します。
SSL化はKUSANAGI専用コマンドを使用することで簡単に設定可能です。
本記事はKUSANAGIの初期設定でWordPressをプロビジョニングしていることを前提に記載しています。

環境

  • KUSANAGI Version8.4.4-3

SSL設定

SSLの設定は以下のコマンドで行います。

kusanagi ssl --email user@example.com

上記はメールアドレスが user@example.comの場合の例です。

実行結果

# kusanagi ssl --email user@example.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for example.com
http-01 challenge for www.example.com
Using the webroot path /home/kusanagi/kusanagi_html/DocumentRoot for all unmatched domains.
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/jbs-inc.net/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/jbs-inc.net/privkey.pem
   Your cert will expire on 2020-08-25. 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

PHP Notice:  Constant RELOCATE already defined in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1198) : eval()'d code on line 96
PHP Notice:  Constant RELOCATE already defined in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1198) : eval()'d code on line 96
証明書の自動更新を有効にします
nginx/httpd の設定を変更し、再起動しました。
完了しました。
新しいメールが /var/spool/mail/root にあります

リダイレクトの設定

リダイレクトの設定は以下のコマンドで行います。

kusanagi ssl --https redirect

実行結果

# kusanagi ssl --https redirect
jbs-inc.net 上のすべてのトラフィックを永久的にHTTPSにリダイレクトするよう設定します。
PHP Notice:  Constant RELOCATE already defined in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1198) : eval()'d code on line 96
PHP Notice:  Constant RELOCATE already defined in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1198) : eval()'d code on line 96
nginx/httpd の設定を変更し、再起動しました。
完了しました。

自動更新の設定

私の場合、メールアドレスを設定した際に、「証明書の自動更新を有効にします」とメッセージが表示され有効になっていましたが明示的に有効化する場合、以下のコマンドを実行します。

kusanagi ssl --auto on

実行結果

# kusanagi ssl --auto on
証明書の自動更新は既に有効です。何もしません。
完了しました。


参考:
https://kusanagi.tokyo/document/command/#ssl

コメント

タイトルとURLをコピーしました