申请Let's Encrypt的证书
允許EPEL倉庫
$ yum -y install yum-utils $ yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional 安裝CertBot $ sudo yum install certbotcertbot需要pyOpenSSL 0.14版本
pip show pyOpenSSL查看版本, centos 7.2默認安裝的pyOpenSSL0.13, 運行certbot會報錯
pip install pyOpenSSL==0.14
certbot在申請證書過程中,會通過訪問待申請域名下面的.well-known/acme-challenge/*來驗證服務是否可訪問,所以需要先配置一下nginx.
在 nginx.conf加入以下配置
location ^~ /.well-known/acme-challenge/ {default_type "text/plain";root /usr/local/nginx-1.10.1/html; }申請證書
參數說明
--webroot 使用webroot plugin
-w webserver的root,/usr/local/nginx-1.10.1/html這是我的nginx的webroot目錄
-d 指定域名,這里是panchan.net.cn, www.panchan.net.cn
生成的證書存放在/etc/letsencrypt/live/panchan.net.cn目錄下面。
自動更新證書
Let's Encrypt申請的免費證書90天會自動過期,可以使用以下命令自動續期
首先運行certbot renew --dry-run, 測試是否可以自動續期,如果返回正確,可以在cron或systemd中添加計劃任務certbot renew實現自動續期。
參考資料
https://letsencrypt.org/
https://letsencrypt.org/docs/
https://certbot.eff.org/#centosrhel7-nginx
總結
以上是生活随笔為你收集整理的申请Let's Encrypt的证书的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Storm部署文档
- 下一篇: AliSQL开源Sequence Eng