【发布时间】:2018-10-30 08:42:11
【问题描述】:
我的虚拟机上的 nginx 正在停止,我无法找出原因。
sudo nginx -t -c /etc/nginx/nginx.conf
返回
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
还有一些日志:
sudo systemctl status nginx.service
日志:
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2018-05-20 12:26:38 UTC; 2h 34min ago
Process: 25083 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 25126 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Process: 25123 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 6426 (code=exited, status=0/SUCCESS)
May 20 12:26:37 sl-code nginx[25126]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
May 20 12:26:37 sl-code nginx[25126]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
May 20 12:26:38 sl-code nginx[25126]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
May 20 12:26:38 sl-code nginx[25126]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
May 20 12:26:38 sl-code nginx[25126]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
May 20 12:26:38 sl-code nginx[25126]: nginx: [emerg] still could not bind()
May 20 12:26:38 sl-code systemd[1]: nginx.service: Control process exited, code=exited status=1
May 20 12:26:38 sl-code systemd[1]: Failed to start A high performance web server and a reverse proxy server.
May 20 12:26:38 sl-code systemd[1]: nginx.service: Unit entered failed state.
May 20 12:26:38 sl-code systemd[1]: nginx.service: Failed with result 'exit-code'.
错误日志: sudo nano /var/log/nginx/error.log
2020/04/17 03:58:54 [notice] 18191#18191: signal process started
2020/04/17 03:58:54 [error] 18191#18191: invalid PID number "" in "/run/nginx.pid"
2020/04/17 03:58:59 [notice] 18195#18195: signal process started
2020/04/17 03:59:05 [emerg] 18238#18238: bind() to 0.0.0.0:80 failed (98: Address already in use)
2020/04/17 03:59:05 [emerg] 18238#18238: bind() to [::]:80 failed (98: Address already in use)
2020/04/17 03:59:05 [emerg] 18238#18238: bind() to 0.0.0.0:443 failed (98: Address already in use)
2020/04/17 03:59:05 [emerg] 18238#18238: bind() to 0.0.0.0:80 failed (98: Address already in use)
2020/04/17 03:59:05 [emerg] 18238#18238: bind() to [::]:80 failed (98: Address already in use)
2020/04/17 03:59:05 [emerg] 18238#18238: bind() to 0.0.0.0:443 failed (98: Address already in use)
【问题讨论】:
-
在 80 和 443 端口上似乎存在一些竞争。虚拟机或虚拟机主机(您的电脑)中是否有任何其他 Web 服务器?也可以在您的主机(不是虚拟机)上使用 Skype,因为它默认使用端口 80(您可以更改它),以防您还将虚拟机端口映射到您的主机端口。
-
问题仍然存在。这是一个 digitalocean droplet,我没有在上面安装任何其他 Web 服务器。
-
试图检查谁在使用端口 80 和 443,结果为空。看起来某个作业进程正在杀死 nginx 进程
标签: nginx debian ubuntu-16.04 ubuntu-server