Lets' encryptを使ってSSL証明書を発行 » 履歴 » バージョン 5
バージョン 4 (蒲池 晃, 2021/07/03 14:53) → バージョン 5/8 (蒲池 晃, 2022/07/20 13:03)
h1. Lets' encryptを使ってSSL証明書を発行
* インストール
<pre>apt-get install certbot</pre>または
<pre>yum -y install certbot</pre>
それでもだめなら
https://nextblog.tokyo/2021%E5%B9%B4%E7%89%88-amazonlinux2-%E3%81%AB%E7%84%A1%E6%96%99%E3%81%AEssl%E8%A8%BC%E6%98%8E%E6%9B%B8-lets-encrypt%EF%BC%88certbot%EF%BC%89%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC/
* 起動
<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
また、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>
* その他の情報
ログの場所 <pre>/var/log/letsencrypt/letsencrypt.log</pre>
更新のコンフィグファイルの場所<pre>/etc/letsencrypt/renewal/redmine.amano-aws.com.conf</pre>
* インストール
<pre>apt-get install certbot</pre>または
<pre>yum -y install certbot</pre>
それでもだめなら
https://nextblog.tokyo/2021%E5%B9%B4%E7%89%88-amazonlinux2-%E3%81%AB%E7%84%A1%E6%96%99%E3%81%AEssl%E8%A8%BC%E6%98%8E%E6%9B%B8-lets-encrypt%EF%BC%88certbot%EF%BC%89%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC/
* 起動
<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
また、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>
* その他の情報
ログの場所 <pre>/var/log/letsencrypt/letsencrypt.log</pre>
更新のコンフィグファイルの場所<pre>/etc/letsencrypt/renewal/redmine.amano-aws.com.conf</pre>