Let's Encryptの設定方法
certbotのインストール
curl https://dl.eff.org/certbot-auto -o /usr/bin/certbot-auto
もしくは
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
証明書の取得
./certbot-auto certonly --agree-tos --webroot -w /home/path/to/dir -d example.com -m info@example.com
証明書の自動更新
httpd.conf等の設定
# Let's Encrypt
SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
basic認証がかかっている場合は
webroot配下に.well-knownディレクトリを作成し、以下の内容の.htaccessファイルをおく
Satisfy any
order allow,deny
allow from all
更新確認
以下のコマンド実行でインストール直後等は更新時期が来ていないのでskipped等になるはず
certbot-auto renew --post-hook "sudo service httpd graceful"
cronに登録する
cronが動いているか確認
/etc/rc.d/init.d/crond status
→running...になったらOK
cronファイル作成
vim /etc/cron.d/letsencrypt
cronファイル登録
毎月1日の16:00から更新確認が動く
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
00 16 1 * * root /usr/bin/certbot-auto renew --post-hook "service httpd graceful"