参考掘金的文章,掘金的文章最详细。
https://juejin.im/post/5a31cbf76fb9a0450b6664ee
先检查是否存在 EPEL
源:
# 进入目录检查是否存在 EPEL 源,一般情况文件名称 epel.repocd /etc/yum.repos.d/
如果不存在可以直接安装
sudo yum install epel-release -y
安装签发证书工具
sudo yum install certbot-nginx -y
来了
报nginx配置文件目录不对错误
sudo 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 # 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: [eme
解决方法,这个解决方法就是让
certbot
认为你的,你的配置存在,并且将SSL配置写入你的nginx配置文件中,然后拷贝配置到你的默认 nginx 配置中。哈哈为了方便 nginx 启动不用指定配置,也没有看到 certbot
工具提供指定目录的命令,暂时我就这么解决吧。 # nginx 默认配置文件目录不 /etc/nginx/ 目录下,
# 需要拷贝/usr/local/nginx/conf目录下的全部文件
# 复制到/etc/nginx/目录下
cp -r /usr/local/nginx/conf/* /etc/nginx/
# 编辑开机启动将所有目录换成/etc/nginx/
vim /lib/systemd/system/nginx.service
cp /lib/systemd/system/nginx.service{,.bak}
# 测试配置是否正确
nginx -t -c /etc/nginx/nginx.conf
作者:小弟调调™ 链接:https://juejin.im/post/5a31cbf76fb9a0450b6664ee 来源:掘金 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。