certbot 自动配置 HTTPS 证书时,指定 nginx 配置文件路径

发布时间: 2020-02-11 21:18:12 作者: 大象笔记

今天在一台 CentOS 7.3 的服务器上配置新网站域名的 HTTPS 证书,Web Server 用的 Nginx。

certbot 提示 nginx.conf 文件找不到。

# certbot --nginx
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Error while running nginx -c /etc/nginx/nginx.conf -t.

nginx: [emerg] open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
nginx: configuration file /etc/nginx/nginx.conf test failed

但是这台服务器是用的某 panel 安装的 Nginx,所以 nginx.conf 文件并不在默认的路径上。查了半天才找到自定义路径的方法:

certbot --nginx --nginx-server-root=/some/other/path/nginx/conf
我是一名山东烟台的开发者,联系作者