一、安装certbot
yum install certbot python2-certbot-nginx
二、普通域名证书
1 、申请ssl证书,有效期90天
certbot certonly -n -d x.x.com --standalone # 证书文件生成到 /etc/letsencrypt/live/x.x.com/ 下 # 参数 -d 可以使用多次来指定多个域名,也可以在一个 -d 参数中使用逗号分隔多个域名 # 参数 --cert-name 可以指定证书文件的父级目录名字(替换默认的 x.x.com)
2、 续签 ssl 证书
cerbot renew --force-renewal
三、泛域名申请
1、 申请 ssl 证书,有效期 90 天。此步需要要求解析域名
certbot certonly --preferred-challenges dns \ --manual -d *.qiuluomu.xyz \ --server https://acme-v02.api.letsencrypt.org/directory
certonly 安装模式
-d 申请证书的域名,如果是通配符域名输入 *.example.com
--manual 手动安装插件
--preferred-challenges dns 使用 DNS 方式校验域名所有权
--server,Let's Encrypt ACME v2 版本使用的服务器不同于 v1 版本,需要显示指定
2、 续签 ssl 证书,使用 certonly 子命令指定域名单独更新
certbot certonly --force-renewal --manual -d '*.qiuluomu.xyz' \ --preferred-challenges dns \ --server https://acme-v02.api.letsencrypt.org/directory
四、域名证书申请过程
1、运行certbot
2、配置DNS TXT记录
到购买域名的服务商控制台解析域名
添加一条TXT记录
主机记录:_acme-challenge.example.com
记录值:pzBqECpVNkjt8gx76qVAYevMFg6n_8dfq-Xqr2f9dI8
记录生效后,回车
3、查看证书
证书目录:/etc/letsencrypt/live/example.com
五、配置nginx
六、续签脚本
/usr/bin/certbot certonly --force-renewal --manual -d '*.qiuluomu.xyz' --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory /usr/local/nginx/sbin/nginx -t [ S? == 0 ] && /usr/local/nginx/sbin/nginx -s reload