プロジェクト

全般

プロフィール

Lets' encryptを使ってSSL証明書を発行 » 履歴 » バージョン 2

バージョン 1 (蒲池 晃, 2021/07/03 14:46) → バージョン 2/8 (蒲池 晃, 2021/07/03 14:49)

h1. Lets' encryptを使ってSSL証明書を発行

* インストール
<pre>apt-get install certbot</pre>または
<pre>yum -y install certbot</pre>

* 起動
<pre>systemctl start certbot</pre>

* 証明書の初回発行
<pre>
certbot certonly --agree-tos --non-interactive -d <ドメイン名> --webroot -w <ドキュメントルート> --email <メールアドレス>
</pre>例)
ドメイン名 redmine.aitp.jp
ドキュメントルート /opt/bitnami/apps/redmine/htdocs/public
メールアドレス akamachi@ait-partner.co.jp

* 下記のようなエラーが出ることがある
<pre>
Problem binding to port 80: Could not bind to IPv4 or IPv6.
</pre>
この場合は、apatchを停止しておくと動く sudo /opt/bitnami/ctlscript.sh stop apache この場合は、apatchを停止しておくと動く
また、port:80が解放されていない場合も同様にエラーになる

* bitnami.conf の修正
<pre>
<VirtualHost *:443>
:
  SSLCertificateKeyFile /etc/letsencrypt/live/<ドメイン名>/privkey.pem
  SSLCertificateFile /etc/letsencrypt/live/<ドメイン名>/cert.pem
  SSLCertificateChainFile /etc/letsencrypt/live/<ドメイン名>/chain.pem
:
</VirtualHost>
</pre>

* APATCH再起動
<pre>
sudo /opt/bitnami/ctlscript.sh restart apache
</pre>

* 証明書の定期更新バッチの作成
こうゆうのを作成してバッチ化しておかないと証明書の有効期限が90日と短い
<pre>
/etc/letsencrypt/letsencrypt-renew.sh
#!/bin/sh
certbot renew -q --no-self-upgrade --post-hook "systemctl restart httpd.service"
</pre>