sertbotをインストールして証明書を取得&設定
yum -y install mod_sslamazon-linux-extras install epel -ysudo yum install -y certbotapatcheを一旦停止(停止しないとエラーになる)
systemctl stop httpdsudo certbot certonly --standalone -d (独自ドメイン) -m (EMAIL)/etc/httpd/conf.d/ssl.confを編集
#SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateFile /etc/letsencrypt/live/(独自ドメイン)/fullchain.pem
#SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
SSLCertificateKeyFile /etc/letsencrypt/live/(独自ドメイン)/privkey.pemapacheを起動
systemctl start httpd証明書の更新
sudo certbot renew --dry-run
sudo certbot renewapatcheは停止しておく
httpアクセスに対してIP制限をしている状況下では失敗する
DNSモードによる更新
python3.8インストール&pipインストール
sudo amazon-linux-extras install -y python3.8
echo 'alias python=python3.8' >> ~/.bashrc
source ~/.bashrc
curl https://bootstrap.pypa.io/get-pip.py | pythoncertbot-dns-rooute53をインストール
pip install certbot certbot-dns-route53Route53のDNS操作に使用するAIMユーザを作成し、
AmazonRoute53FullAccessポリシーをアタッチする。
アクセスキーとシークレットアクセスキーを取得し、下記のように設定。
mkdir -p ~/.aws
vi ~/.aws/credentials
aws sts get-caller-identity (設定後認証情報を確認)[default]
aws_access_key_id = YOUR_ACCESS_KEY_ID
aws_secret_access_key = YOUR_SECRET_ACCESS_KEYDNSモードで証明書を更新
certbot certonly \
--dns-route53 \
--domain [ドメイン] \
--email [メールアドレス] \
--agree-tos \
--preferred-challenges dns \
--renew-by-default \
--textapacheを再起動
systemctl restart httpdDNSモードによる更新(自動化)
証明書更新用のシェルを作成
vi certbot-update.sh#!/bin/bash
certbot certonly \
--dns-route53 \
--domain [ドメイン] \
--email [メールアドレス] \
--agree-tos \
--preferred-challenges dns \
--renew-by-default \
--textchmod 755 certbot-update.sh作成したシェルをcronに登録
0 0 1 */3 * /root/certbot-update.sh
#3ヶ月ごと、1日0時0分にcertbot-update.shを自動実行します
#3月1日0時0分 6月1日0時0分 9月1日0時0分