プロジェクト

全般

プロフィール

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

蒲池 晃, 2021/07/03 14:53

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