發(fā)表日期:2018-03 文章編輯:小燈 瀏覽次數(shù):3484
Let’s Encrypt是很火的一個免費SSL證書發(fā)行項目,自動化發(fā)行證書,證書有90天的有效期。而且支持多域名使用同一個證書,這很方便。
安裝方法:
如果是CentOS 6、7,先執(zhí)行:yum install -y epel-release
wget https://dl.eff.org/certbot-auto --no-check-certificate
chmod +x ./certbot-auto
1.單一域名生成SSL證書
./certbot-auto certonly --email zhang651651@hotmail.com --agree-tos --no-eff-email --webroot -w /home/wwwroot/a.com -d a.com
OR
2.多域名單目錄生成一個SSL證書
./certbot-auto certonly --email zhang651651@hotmail.com --agree-tos --no-eff-email --webroot -w /home/wwwroot/a.com -d a.com -d b.com -d c.com
OR
3.多域名多目錄生成一個證書:(即一次生成多個域名的一個證書)
./certbot-auto certonly --email zhang651651@hotmail.com --agree-tos --no-eff-email --webroot -w /home/wwwroot/a.com -d a.com -d www.a.com -w /home/wwwroot/lnmp.org -d www.lnmp.org -d lnmp.org
跑完上面命令,如果成功的話,會出現(xiàn):
IMPORTANT NOTES:
生成的證書會存在:/etc/letsencrypt/live/a.com/ 目錄下。
改完配置文件切記重啟或reload nginx。
證書續(xù)期
cerrbot的續(xù)期比原來的更加簡單,因為證書只有90天,所以建議使用crontab進行自動續(xù)期:
crontab 里加上如下規(guī)則:
0 3 */5 * * /root/certbot-auto renew --disable-hook-validation --renew-hook "/etc/init.d/nginx reload"
這樣每5天就會執(zhí)行一次所有域名的續(xù)期操作。當(dāng)然時間也可以自行進行調(diào)整,建議別太頻繁,因為他們都有請求次數(shù)的限制,如果需要強制更新可以在前面命令上加上 --force-renew 參數(shù)。
注意事項:
1、因為默認LNMP的虛擬主機里是禁止 . 開頭的隱藏文件及目錄的,所以訪問http://a.com/.well-known/acme-challenge/**** 這個鏈接的話返回403錯誤,所以必須要將對應(yīng)虛擬主機配置文件里的
location ~ /.
{
deny all;
}
location ~ /.well-known {
allow all;
}
以上配置代碼,然后重啟nginx。
或者直接去下面這個網(wǎng)址申請,一樣的。
https://www.sslforfree.com/