有没有办法解决 CENTOS 中 nginx 状态 Active: inactive (dead) 的问题

Rum*_*ble 7 nginx

这是检查 nginx 状态时带来的结果

\n\n
[root@ttproxyapp conf.d]# service nginx status\nRedirecting to /bin/systemctl status nginx.service\n\xe2\x97\x8f nginx.service - nginx - high performance web server\n   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)\n   Active: inactive (dead)\n
Run Code Online (Sandbox Code Playgroud)\n

小智 17

sudo systemctl stop apache2
sudo systemctl start nginx
Run Code Online (Sandbox Code Playgroud)

应该可以工作,因为看起来端口正在使用中(可能与 apache 一起使用)


Tim*_*ark 2

看起来你的 NGINX 确实没有运行。nginx -s reload如果有一个正在运行的实例并且因此有一个 PID 文件,那么它就可以工作。

\n\n

请检查以下命令的结果。

\n\n
[root@localhost conf.d]# sudo ps -elf | grep nginx\n
Run Code Online (Sandbox Code Playgroud)\n\n

应该是这样的

\n\n
1 S root      88262      1  0  80   0 - 13143 sigsus 23:47 ?        00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf\n5 S nginx     88263  88262  0  80   0 - 13257 ep_pol 23:47 ?        00:00:00 nginx: worker process\n0 R root      88265  69227  0  80   0 - 28178 -      23:47 pts/1    00:00:00 grep --color=auto nginx\n
Run Code Online (Sandbox Code Playgroud)\n\n

你至少需要!主进程和工作进程!如果没有进程,请输入以下命令启动您的实例

\n\n

sudo /bin/systemctl start nginx.service或者sudo service nginx start

\n\n

运行命令后检查您的进程列表。

\n\n

启动 NGINX 服务后,应该有位于 \n 的 PID 文件/var/run/nginx.pid,并且sudo systemctl status nginx.service应该打印出类似的内容

\n\n
[root@localhost conf.d]# systemctl status nginx.service\n\xe2\x97\x8f nginx.service - NGINX Plus - high performance web server\n   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)\n   Active: active (running) since Sat 2020-03-14 23:47:13 EDT; 5min ago\n     Docs: https://www.nginx.com/resources/\n  Process: 88232 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)\n  Process: 88260 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)\n  Process: 88251 ExecStartPre=/usr/libexec/nginx-plus/check-subscription (code=exited, status=0/SUCCESS)\n Main PID: 88262 (nginx)\n    Tasks: 2\n   Memory: 1.7M\n   CGroup: /system.slice/nginx.service\n           \xe2\x94\x9c\xe2\x94\x8088262 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf\n           \xe2\x94\x94\xe2\x94\x8088263 nginx: worker process\n\nMar 14 23:47:13 localhost.localdomain systemd[1]: Starting NGINX Plus - high performance web server...\nMar 14 23:47:13 localhost.localdomain systemd[1]: Can't open PID file /var/run/nginx.pid (yet?) after start: No such file or directory\nMar 14 23:47:13 localhost.localdomain systemd[1]: Started NGINX Plus - high performance web server.\n
Run Code Online (Sandbox Code Playgroud)\n\n

我正在运行 NGINX Plus,但在这种情况下并不重要。

\n