例1. apacheにLet's Encryptを導入する方法
# sudo su
# yum -y install certbot certbot-apache
# certbot run --apache -d www.sample.com -d sample.com
> メアド入力
> httpからhttpsへのリダイレクトをするなら2を選択
# systemctl status crond
# vim /etc/cron.d/letsencrypt
0 23 * * 7 root /bin/certbot renew --post-hook "systemctl restart httpd"
更新に失敗した場合は、一度Webサーバーを停止して以下を実行
# /bin/certbot renew
例2. amazonlinux2のNginxにLet's Encryptを導入
# cd /etc/pki
# wget https://dl.eff.org/certbot-auto
# chmod a+x certbot-auto
# cp certbot-auto{,_ORG}
# vim certbot-auto
843行目の
elif [ -f /etc/issue ] && grep -iq "Amazon Linux" /etc/issue ; then
をコメントアウトして
elif grep -i "Amazon Linux" /etc/issue > /dev/null 2>&1 || \
grep 'cpe:.*:amazon_linux:2' /etc/os-release > /dev/null 2>&1; then
# systemctl stop nginx
# ./certbot-auto certonly --standalone -d sample.com --debug -m mail@pear.jp --agree-tos
# vim /etc/nginx/conf.d/sample.com.conf
serverディレクティブの中に
ssl_certificate /etc/letsencrypt/live/sample.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/sample.com/privkey.pem;
を追加
# systemctl restart nginx
# vim /etc/cron.d/letsencrypt
0 24 * * 7 root /etc/pki/certbot-auto renew --post-hook "systemctl restart nginx"
トップへ