Home » Code » 免费ssl证书letsencrypt的使用


官网有提供工具,在 https://certbot.eff.org/ 上选择所用的web软件和系统,就能看到操作步骤。

但这个自动软工具好像把某些路径定死了,比如读取 nginx 配置文件就固定成了 /etc/nginx/nginx.conf,可能会遇到以下报错:

[root@iZuf6jcwx7sfb1h6ayjq99Z ~]# ./certbot-auto --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

The nginx plugin is not working; there may be problems with your existing configuration.
The error was: MisconfigurationError('Error while running nginx -c /etc/nginx/nginx.conf -t.\n\nnginx: [emerg] open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)\nnginx: configuration file /etc/nginx/nginx.conf test failed\n',)

这时候需要把 nginx 实际的配置文件链接到 /etc/nginx/nginx.conf,这里我用的 openresty,执行:ln -s /usr/local/openresty/nginx/conf/* /etc/nginx,完成链接。

从报错中也可以明显的看出,它直接执行 nginx 命令,如果 nginx 命令不在环境变量中,也需要链接一下:ln -s /usr/local/openresty/nginx/sbin/nginx /usr/bin/nginx。


Leave a Reply

Your email address will not be published. Required fields are marked *


Time limit is exhausted. Please reload CAPTCHA.