Debian系统移步:
Nginx + CertBot 配置HTTPS泛域名证书(Debian)
# 安装nginx
此步省略, 以nginx安装在'/usr/local/nginx-1.23.3'目录为例
# 安装certbot
yum install certbot python2-certbot-nginx -y
# 自动配置, --nginx-server-root指定nginx配置文件目录
certbot --nginx --nginx-server-root /usr/local/nginx-1.23.3/conf
# 自动续约
certbot renew --dry-run
执行完后nginx.conf会自动加上SSL相关配置
常见问题
执行certbot --nginx --nginx-server-root /usr/local/nginx-1.23.3/conf
命令报错:
Saving debug log to /var/log/letsencrypt/letsencrypt.log
The nginx plugin is not working; there may be problems with your existing configuration.
The error was: NoInstallationError("Could not find a usable 'nginx' binary. Ensure nginx exists, the binary is executable, and your PATH is set correctly.",)
解决方案:
ln -s /usr/local/nginx-1.23.3/sbin/nginx /usr/bin/nginx
ln -s /usr/local/nginx-1.23.3/conf/ /etc/nginx