Let’s EncryptによるSSL化

# cd /root
python2.7インストール
# yum install centos-release-SCL
# yum install python27 python27-python-tools
# yum install dialog
python2.7有効化
# scl enable python27 bash
# python --version
# Python 2.7.8
certbotインストール
※yum updateでもろもろのパッケージを最新にしないとGitのチェックアウトができなかった。
# yum install git
# git clone https://example@github.com/certbot/certbot
Initialized empty Git repository in /root/certbot/.git/
Password: githubのパスワード入力
# cd certbot
# service httpd stop
証明書作成
# ./certbot-auto certonly --standalone --email example@example.com -d example.com
証明書が作成されているか確認
# ls -l /etc/letsencrypt/live/example.com
証明書設定
# vi /etc/httpd/conf.d/ssl.conf
    SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem ←もともとコメントアウトしていたので有効化
を記載。
再起動して有効化
# service httpd restart
自動更新スクリプト
# mkdir /root/certbot/scripts
# mkdir /root/certbot/logs
# vi /root/certbot/scripts/encrypt-renew-script.sh
	#!/bin/bash
	/etc/rc.d/init.d/httpd stop
	/usr/bin/scl enable python27 '/root/certbot/certbot-auto renew > /root/certbot/logs/renew.log 2>&1'
	/etc/rc.d/init.d/httpd start
# chmod +x /root/certbot/scripts/encrypt-renew-script.sh
cron設定
# sudo crontab -u root -e  # サービスの停止/開始のためrootで
# 以下を書く 毎月25日6時の設定
00 06 25 * * /root/certbot/scripts/encrypt-renew-script.sh > /dev/null 2>&1

参考:https://blog.yagi2.com/2016/08/31/lets-encrypt.html

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です