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