问题一 nginx: [emerg] open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
[root ~]# certbot certonly --nginx -d ikarp.top -d www.ikarp.top -d blog.ikarp.top
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
Could not choose appropriate plugin: 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',)
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.conf
[root ~]# locate nginx.conf /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.default
创建软链
[root ~]# ln -s /usr/local/nginx/conf/nginx.conf /etc/nginx/nginx.conf ln: failed to create symbolic link ‘/etc/nginx/nginx.conf’: No such file or directory # 缺少目录文件, 创建/etc/nginx [root ~]# mkdir -p /etc/nginx/ # 再次创建软链 [root ~]# ln -s /usr/local/nginx/conf/nginx.conf /etc/nginx/nginx.conf
问题二 nginx: [emerg] open() "/etc/nginx/mime.types" failed (2: No such file or directory) in /etc/nginx/nginx.conf:18
[root ~]# certbot certonly --nginx -d ikarp.top -d www.ikarp.top -d blog.ikarp.top
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Error while running nginx -c /etc/nginx/nginx.conf -t.
nginx: [emerg] open() "/etc/nginx/mime.types" failed (2: No such file or directory) in /etc/nginx/nginx.conf:18
nginx: configuration file /etc/nginx/nginx.conf test failed
Could not choose appropriate plugin: 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/mime.types" failed (2: No such file or directory) in /etc/nginx/nginx.conf:18\nnginx: configuration file /etc/nginx/nginx.conf test failed\n',)
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/mime.types" failed (2: No such file or directory) in /etc/nginx/nginx.conf:18\nnginx: configuration file /etc/nginx/nginx.conf test failed\n',)
解决方式同上, 创建软链
[root ~]# locate mime.types
/etc/mime.types
/usr/local/nginx/conf/mime.types
/usr/local/nginx/conf/mime.types.default
[root ~]# ln -s /usr/local/nginx/conf/mime.types /etc/nginx/mime.types
结束
[root ~]# certbot certonly --nginx -d ikarp.top -d www.ikarp.top
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org
Requesting a certificate for ikarp.top and www.ikarp.top
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/ikarp.top/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/ikarp.top/privkey.pem
Your certificate will expire on 2025-01-17. To obtain a new or
tweaked version of this certificate in the future, simply run
certbot again. To non-interactively renew *all* of your
certificates, run "certbot renew"
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le