免费SSL证书Let's Encrypt(certbot)安装使用教程

安装方法:
如果是CentOS 6、7,先执行:yum install epel-release

cd /root/
wget https://dl.eff.org/certbot-auto --no-check-certificate
chmod +x ./certbot-auto
./certbot-auto -n
./certbot-auto -n只是用来安装依赖包的,也可以跳过直接到下面的生成证书的步骤,国内VPS或服务器上使用的话建议先修改为国内的pip源。

修改pip源为国内的:
mkdir ~/.pip
cat > ~/.pip/pip.conf <<EOF
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=https://pypi.tuna.tsinghua.edu.cn
EOF

单域名生成证书:
./certbot-auto certonly --email youemail@vpser.net --agree-tos --no-eff-email --webroot -w /home/wwwroot/www.vpser.net -d www.vpser.net

多域名单目录生成单证书:(即一个网站多个域名使用同一个证书)

./certbot-auto certonly --email youemail@vpser.net --agree-tos --no-eff-email --webroot -w /home/wwwroot/www.vpser.net -d www.vpser.net -d bbs.vpser.net

多域名多目录生成一个证书:(即一次生成多个域名的一个证书)
/certbot-auto certonly --email youemail@vpser.net --agree-tos --no-eff-email --webroot -w /home/wwwroot/www.vpser.net -d www.vpser.net -d bbs.vpser.net -w /home/wwwroot/lnmp.org -d www.lnmp.org -d lnmp.org
就是生成成功。

生成的证书会存在:/etc/letsencrypt/live/www.vpser.net/ 目录下

证书续期
cerrbot的续期比原来的更加简单,因为证书只有90天,所以建议使用crontab进行自动续期:

crontab 里加上如下规则:0 3 /5 * /root/certbot-auto renew --disable-hook-validation --renew-hook "/etc/init.d/nginx reload" 这样每5天就会执行一次所有域名的续期操作。当然时间也可以自行进行调整,建议别太频繁,因为他们都有请求次数的限制,如果需要强制更新可以在前面命令上加上 --force-renew 参数。

标签: none

评论已关闭