Lets' encryptを使ってSSL証明書を発行 » 履歴 » バージョン 5
蒲池 晃, 2022/07/20 13:03
1 | 1 | 蒲池 晃 | h1. Lets' encryptを使ってSSL証明書を発行 |
---|---|---|---|
2 | 1 | 蒲池 晃 | |
3 | 1 | 蒲池 晃 | * インストール |
4 | 1 | 蒲池 晃 | <pre>apt-get install certbot</pre>または |
5 | 1 | 蒲池 晃 | <pre>yum -y install certbot</pre> |
6 | 5 | 蒲池 晃 | それでもだめなら |
7 | 5 | 蒲池 晃 | 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/ |
8 | 1 | 蒲池 晃 | |
9 | 1 | 蒲池 晃 | * 起動 |
10 | 1 | 蒲池 晃 | <pre>systemctl start certbot</pre> |
11 | 1 | 蒲池 晃 | |
12 | 1 | 蒲池 晃 | * 証明書の初回発行 |
13 | 1 | 蒲池 晃 | <pre> |
14 | 1 | 蒲池 晃 | certbot certonly --agree-tos --non-interactive -d <ドメイン名> --webroot -w <ドキュメントルート> --email <メールアドレス> |
15 | 1 | 蒲池 晃 | </pre>例) |
16 | 1 | 蒲池 晃 | ドメイン名 redmine.aitp.jp |
17 | 1 | 蒲池 晃 | ドキュメントルート /opt/bitnami/apps/redmine/htdocs/public |
18 | 1 | 蒲池 晃 | メールアドレス akamachi@ait-partner.co.jp |
19 | 1 | 蒲池 晃 | |
20 | 1 | 蒲池 晃 | * 下記のようなエラーが出ることがある |
21 | 1 | 蒲池 晃 | <pre> |
22 | 1 | 蒲池 晃 | Problem binding to port 80: Could not bind to IPv4 or IPv6. |
23 | 1 | 蒲池 晃 | </pre> |
24 | 2 | 蒲池 晃 | この場合は、apatchを停止しておくと動く sudo /opt/bitnami/ctlscript.sh stop apache |
25 | 1 | 蒲池 晃 | また、port:80が解放されていない場合も同様にエラーになる |
26 | 1 | 蒲池 晃 | |
27 | 1 | 蒲池 晃 | * bitnami.conf の修正 |
28 | 1 | 蒲池 晃 | <pre> |
29 | 1 | 蒲池 晃 | <VirtualHost *:443> |
30 | 1 | 蒲池 晃 | : |
31 | 1 | 蒲池 晃 | SSLCertificateKeyFile /etc/letsencrypt/live/<ドメイン名>/privkey.pem |
32 | 1 | 蒲池 晃 | SSLCertificateFile /etc/letsencrypt/live/<ドメイン名>/cert.pem |
33 | 1 | 蒲池 晃 | SSLCertificateChainFile /etc/letsencrypt/live/<ドメイン名>/chain.pem |
34 | 1 | 蒲池 晃 | : |
35 | 1 | 蒲池 晃 | </VirtualHost> |
36 | 2 | 蒲池 晃 | </pre> |
37 | 2 | 蒲池 晃 | |
38 | 2 | 蒲池 晃 | * APATCH再起動 |
39 | 2 | 蒲池 晃 | <pre> |
40 | 2 | 蒲池 晃 | sudo /opt/bitnami/ctlscript.sh restart apache |
41 | 2 | 蒲池 晃 | </pre> |
42 | 2 | 蒲池 晃 | |
43 | 2 | 蒲池 晃 | * 証明書の定期更新バッチの作成 |
44 | 2 | 蒲池 晃 | こうゆうのを作成してバッチ化しておかないと証明書の有効期限が90日と短い |
45 | 2 | 蒲池 晃 | <pre> |
46 | 2 | 蒲池 晃 | /etc/letsencrypt/letsencrypt-renew.sh |
47 | 2 | 蒲池 晃 | #!/bin/sh |
48 | 2 | 蒲池 晃 | certbot renew -q --no-self-upgrade --post-hook "systemctl restart httpd.service" |
49 | 1 | 蒲池 晃 | </pre> |
50 | 3 | 蒲池 晃 | |
51 | 3 | 蒲池 晃 | * その他の情報 |
52 | 3 | 蒲池 晃 | ログの場所 <pre>/var/log/letsencrypt/letsencrypt.log</pre> |
53 | 3 | 蒲池 晃 | 更新のコンフィグファイルの場所<pre>/etc/letsencrypt/renewal/redmine.amano-aws.com.conf</pre> |