Certbot免費https證書
Certbot免費https證書
Certbot 的官方網站是 https://certbot.eff.org/
當前工作目錄為 /root
-
獲取certbot
wget https://dl.eff.org/certbot-auto chmod a+x certbot-auto
-
停止nginx
service nginx stop
-
生成證書
#使用-d追加多個域名 ./certbot-auto certonly --standalone --email cdw.me@qq.com --agree-tos -d cdw.me -d www.cdw.me -d wiki.cdw.me
-
查看生成的證書
ls /etc/letsencrypt/live/
-
在nginx配置證書
ssl_certificate /etc/letsencrypt/live/cdw.me/fullchain.pem;#證書位置 ssl_certificate_key /etc/letsencrypt/live/cdw.me/privkey.pem;# 私鑰位置
-
啟動nginx
service nginx start
-
編寫更新腳本renew-cert.sh
#!/bin/bash # 停止nginx service nginx stop # 續簽 # --force-renew 強製更新 /root/certbot-auto renew --force-renew # 啟動nginx service nginx start
chmod a+x renew-cert.sh
-
自動更新https證書
//crontab定時任務自動更新證書 0 4 1 */2 * /root/renew-cert.sh >> /root/crontab.log 2>&1
Let’s Encrypt 生成的免費證書為3個月時間,但是我們可以無限次續簽證書
最後更新:2017-07-23 20:33:40