无法启动 nginx:“code=exited,status=1/FAILURE”

无法启动 nginx:“code=exited,status=1/FAILURE”

我刚刚在 Debian Jessie 上安装了 nginx,但无法启动它:

$ sudo /etc/init.d/nginx start
[....] Starting nginx (via systemctl): nginx.serviceJob for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.
 failed!

$ systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
   Active: failed (Result: exit-code) since Sat 2015-08-29 17:54:15 EDT; 6s ago
  Process: 16824 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
  Process: 8407 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
 Main PID: 691 (code=exited, status=0/SUCCESS)

我已经运行netstat -a -b并查看了列表,但没有看到在端口 80 上运行的任何其他程序。

我该如何调试它?

更新:尝试sudo nginx -t查看是否产生了任何有用的信息:

$ sudo nginx -t
nginx: [emerg] BIO_new_file("/etc/nginx/certificates/certificate-178724.crt") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/nginx/certificates/certificate-123353.crt','r') error:2006D080:BIO routines:BIO_new_file:no such file)
nginx: configuration file /etc/nginx/nginx.conf test failed

答案1

的输出nginx -t告诉了你所有需要知道的信息——它无法读取你的配置所引用的证书文件。在 中搜索/etc/nginx该文件的提及,你就会找到该文件所引用的文件。

有趣的是,在 systemd 出现之前的可怕黑暗时期,nginx init 脚本会直接给出该错误。为新世界秩序再添一项可用性胜利!

相关内容