215 字
1 分钟
Nginx+ CertBot配置HTTPS泛域名证书(Debian)
执行完后 nginx.conf 会自动加上 SSL 相关配置
2025-11-10
0 次
0 人
安装 Nginx
apt install nginx配置证书
# 1. 安装certbotapt-get install certbot python3-certbot-nginx
# 2. 获取证书# 自动配置, --nginx-server-root指定nginx配置文件目录certbot --nginx --nginx-server-root /usr/local/nginx-1.23.3/conf# 指定域名, example.com换成自己的域名certbot --nginx -d example.com -d www.example.com
# 3. 自动续约certbot renew --dry-run执行完后 nginx.conf 会自动加上 SSL 相关配置
常见问题
问题一、第 2 步获取证书报错:
Error while running nginx -c /usr/local/nginx-1.25.4/conf/nginx.conf -t.
nginx: the configuration file /usr/local/nginx-1.25.4/conf/nginx.conf syntax is ok2024/03/11 10:42:44 [emerg] 1985275#1985275: open() "/usr/share/nginx/logs/xxx_admin.access.log" failed (2: No such file or directory)nginx: configuration file /usr/local/nginx-1.25.4/conf/nginx.conf test failed创建/usr/share/nginx/logs目录, 重新执行第 2 步命令
问题二、执行certbot --nginx --nginx-server-root /usr/local/nginx-1.23.3/conf命令报错:
Saving debug log to /var/log/letsencrypt/letsencrypt.logThe 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/nginxln -s /usr/local/nginx-1.23.3/conf/ /etc/nginx发现错误或想要改进这篇文章?
在 GitHub 上编辑此页 Nginx+ CertBot配置HTTPS泛域名证书(Debian)