![Nginx服务一直不停,怎么办?](https://linux22.com/image/180330/Nginx%E6%9C%8D%E5%8A%A1%E4%B8%80%E7%9B%B4%E4%B8%8D%E5%81%9C%EF%BC%8C%E6%80%8E%E4%B9%88%E5%8A%9E%EF%BC%9F.png)
我在一台新买的服务器上,装有 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.
谢谢