Nginx服务一直不停,怎么办?

Nginx服务一直不停,怎么办?

我在一台新买的服务器上,装有 CentOS 8 和最新的 Nginx。

我尝试停止 Nginx:

[root@mymachine run]# nginx -s stop
nginx: [error] invalid PID number "" in "/run/nginx.pid"

不工作。

网络仍然有效。我可以用来curl -I http://mysite.com查看输出:

HTTP/1.1 200 OK
Server: nginx/1.14.1

我发现了很多过程:

[root@mymachine run]# ps -aux | grep "nginx"
root       22584  0.0  0.1 156164 11292 ?        S    Sep17   0:03 nginx: worker process
root       22585  0.0  0.1 155836 10832 ?        S    Sep17   0:00 nginx: worker process
root       22586  0.0  0.1 155836  9348 ?        S    Sep17   0:00 nginx: worker process
root       22587  0.0  0.1 155836  9348 ?        S    Sep17   0:00 nginx: worker process
root       22588  0.0  0.1 155836  9348 ?        S    Sep17   0:00 nginx: worker process
root       22589  0.0  0.1 155836  9348 ?        S    Sep17   0:00 nginx: worker process
root       22590  0.0  0.1 155836  9348 ?        S    Sep17   0:00 nginx: worker process
root       22591  0.0  0.1 155836  9348 ?        S    Sep17   0:00 nginx: worker process
root       22592  0.0  0.1 155836  9144 ?        S    Sep17   0:00 nginx: cache manager process
root       26125  0.0  0.0  12108  1080 pts/0    S+   09:11   0:00 grep --color=auto nginx

我应该怎么做才能完全关闭 nginx?

为什么会发生这种情况?

更新为systemctl 状态 nginx.service结果:

[root@mymachine ~]# systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2020-09-18 09:34:52 CST; 20min ago
  Process: 1868 ExecStart=/usr/sbin/nginx (code=exited, status=1/FAILURE)
  Process: 1865 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 1862 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)

Sep 18 09:34:51 mymachine nginx[1868]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Sep 18 09:34:51 mymachine nginx[1868]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Sep 18 09:34:51 mymachine nginx[1868]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Sep 18 09:34:51 mymachine nginx[1868]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Sep 18 09:34:52 mymachine nginx[1868]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Sep 18 09:34:52 mymachine nginx[1868]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Sep 18 09:34:52 mymachine nginx[1868]: nginx: [emerg] still could not bind()
Sep 18 09:34:52 mymachine systemd[1]: nginx.service: Control process exited, code=exited status=1
Sep 18 09:34:52 mymachine systemd[1]: nginx.service: Failed with result 'exit-code'.
Sep 18 09:34:52 mymachine systemd[1]: Failed to start The nginx HTTP and reverse proxy server.

谢谢

相关内容