全球主机交流论坛

标题: 军哥lnmp1.7重启后nginx无法自启 [打印本页]

作者: yxw886    时间: 2020-9-23 01:02
标题: 军哥lnmp1.7重启后nginx无法自启
本帖最后由 yxw886 于 2020-9-23 01:09 编辑

一开始都是正常的,服务器重启nginx还会自动启动,突然今天重启服务器,发现网站打不开了,systemctl status nginx,提示
● nginx.service - The NGINX HTTP and reverse proxy server
   Loaded: loaded (/etc/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2020-09-23 00:27:22 CST; 1min 17s ago
  Process: 1632 ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=1/FAILURE)
Main PID: 1095 (code=killed, signal=KILL)

Sep 23 00:27:22 web.novalocal kill[1632]: -q, --queue <sig>      use sigqueue(2) rather than kill(2)
Sep 23 00:27:22 web.novalocal kill[1632]: -p, --pid              print pids without signaling them
Sep 23 00:27:22 web.novalocal kill[1632]: -l, --list [=<signal>] list signal names, or convert one to a name
Sep 23 00:27:22 web.novalocal kill[1632]: -L, --table            list signal names and numbers
Sep 23 00:27:22 web.novalocal kill[1632]: -h, --help     display this help and exit
Sep 23 00:27:22 web.novalocal kill[1632]: -V, --version  output version information and exit
Sep 23 00:27:22 web.novalocal kill[1632]: For more details see kill(1).
Sep 23 00:27:22 web.novalocal systemd[1]: nginx.service: control process exited, code=exited status=1
Sep 23 00:27:22 web.novalocal systemd[1]: Unit nginx.service entered failed state.
Sep 23 00:27:22 web.novalocal systemd[1]: nginx.service failed.


使用nginx -t,检查没问题
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

输入journalctl -xe,向上翻几页,看到:
Sep 23 00:27:22 web.novalocal systemd[1]: Starting (null)...
-- Subject: Unit selinux.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit selinux.service has begun starting up.
Sep 23 00:27:22 web.novalocal systemd[1]: nginx.service: main process exited, code=killed, status=9/KILL
Sep 23 00:27:22 web.novalocal kill[1632]: Usage:
Sep 23 00:27:22 web.novalocal kill[1632]: kill [options] <pid|name> [...]
Sep 23 00:27:22 web.novalocal kill[1632]: Options:
Sep 23 00:27:22 web.novalocal kill[1632]: -a, --all              do not restrict the name-to-pid conversion to processes
Sep 23 00:27:22 web.novalocal kill[1632]: with the same uid as the present process
Sep 23 00:27:22 web.novalocal kill[1632]: -s, --signal <sig>     send specified signal
Sep 23 00:27:22 web.novalocal kill[1632]: -q, --queue <sig>      use sigqueue(2) rather than kill(2)
Sep 23 00:27:22 web.novalocal kill[1632]: -p, --pid              print pids without signaling them
Sep 23 00:27:22 web.novalocal kill[1632]: -l, --list [=<signal>] list signal names, or convert one to a name
Sep 23 00:27:22 web.novalocal kill[1632]: -L, --table            list signal names and numbers
Sep 23 00:27:22 web.novalocal kill[1632]: -h, --help     display this help and exit
Sep 23 00:27:22 web.novalocal kill[1632]: -V, --version  output version information and exit
Sep 23 00:27:22 web.novalocal kill[1632]: For more details see kill(1).
Sep 23 00:27:22 web.novalocal systemd[1]: nginx.service: control process exited, code=exited status=1
Sep 23 00:27:22 web.novalocal systemd[1]: Unit nginx.service entered failed state.
Sep 23 00:27:22 web.novalocal systemd[1]: nginx.service failed.
Sep 23 00:27:22 web.novalocal cloud-init[1605]: Cloud-init v. 0.7.9 running 'modules:final' at Tue, 22 Sep 2020 16:27:22 +0000. Up 12.09 seconds.
Sep 23 00:27:22 web.novalocal systemd[1]: Started Dynamic System Tuning Daemon.
-- Subject: Unit tuned.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit tuned.service has finished starting up.
--
-- The start-up result is done.


手动输入 systemctl start nginx,可以启动,网站可以正常打开,输入systemctl status nginx,提示:
● nginx.service - The NGINX HTTP and reverse proxy server
   Loaded: loaded (/etc/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2020-09-23 00:41:20 CST; 4s ago
  Process: 1632 ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=1/FAILURE)
  Process: 2738 ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 2739 (nginx)
    Tasks: 5
   Memory: 82.5M
   CGroup: /system.slice/nginx.service
           ├─2739 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
           ├─2740 nginx: worker process
           ├─2741 nginx: worker process
           ├─2742 nginx: worker process
           └─2743 nginx: worker process

Sep 23 00:41:20 web.novalocal systemd[1]: Starting The NGINX HTTP and reverse proxy server...
Sep 23 00:41:20 web.novalocal systemd[1]: Started The NGINX HTTP and reverse proxy server.


有大神知道什么原因吗?

作者: 16qf    时间: 2020-9-23 01:19
不知道,紫薯布丁,楼下解答
作者: caddy    时间: 2020-9-23 01:20
没看你日志,这样看日志看得眼花,系统直接看,错误部分是可以标红

试下重激活看看

systemctl enable nginx.service
作者: llyang    时间: 2020-9-23 01:35
systemctl enable nginx
reboot
systemctl status nginx
看看啥情况,理论上应该没问题

如果不行,查看log报告
作者: yxw886    时间: 2020-9-23 01:41
caddy 发表于 2020-9-23 01:20
没看你日志,这样看日志看得眼花,系统直接看,错误部分是可以标红

试下重激活看看

输入systemctl enable nginx.service后,重启,还是不会自启


作者: yxw886    时间: 2020-9-23 01:42
llyang 发表于 2020-9-23 01:35
systemctl enable nginx
reboot
systemctl status nginx

试过,还是不行,是查看/usr/local/nginx/logs/error.log吗?
作者: benetton    时间: 2020-9-23 02:22
检查一下LOG档是否太大 空间满了 也会这样
作者: fcurrk    时间: 2020-9-23 06:29
用军哥的命令管理nginx。
作者: 唐王李世民    时间: 2020-9-23 08:30
查看你的nginx配置或网站配置
作者: llyang    时间: 2020-9-23 08:53
yxw886 发表于 2020-9-23 01:42
试过,还是不行,是查看/usr/local/nginx/logs/error.log吗?

如果有这个文件,就是的。

如果没找到这个文件,在.conf中查找这个文件。文件名称、位置,都在这里定义。
作者: 1819    时间: 2020-9-23 09:44
提示: 作者被禁止或删除 内容自动屏蔽
作者: biubiu    时间: 2020-9-23 09:50
debian系统吗?我遇到这问题,后来折腾不过

换系统好了
作者: mjj不是我    时间: 2020-9-23 09:59
启动命令:lnmp nginx start

作者: yxw886    时间: 2020-9-23 10:01
1819 发表于 2020-9-23 09:44
看错误日志, 看错误日志.
也有 可能 是 nginx pid问题.
看一下端口占用, 有时候, nginx 已经启动了,

错误日志怎么查看呢?在那个路径呢。80端口没有被占用,nginx进程没找到,每次都是要手动systemctl start nginx才能起来,或者lnmp nginx start之类的命令才能启动
作者: yxw886    时间: 2020-9-23 10:05
biubiu 发表于 2020-9-23 09:50
debian系统吗?我遇到这问题,后来折腾不过

换系统好了

centos 7.4的
作者: 1819    时间: 2020-9-23 10:08
提示: 作者被禁止或删除 内容自动屏蔽
作者: yxw886    时间: 2020-9-23 10:11
mjj不是我 发表于 2020-9-23 09:59
启动命令:lnmp nginx start

这样是可以启动,但是每次开机不会自动启动nginx,但mysql、php可以
作者: yxw886    时间: 2020-9-23 10:18
llyang 发表于 2020-9-23 08:53
如果有这个文件,就是的。

如果没找到这个文件,在.conf中查找这个文件。文件名称、位置,都在这里定义 ...

恩,有这个文件
2020/09/02 11:44:39 [notice] 31091#0: signal process started
2020/09/02 11:46:25 [notice] 31233#0: signal process started
2020/09/02 13:41:18 [notice] 22336#0: signal process started
2020/09/02 13:55:23 [notice] 22939#0: signal process started
2020/09/02 14:04:24 [notice] 23231#0: signal process started
2020/09/02 14:06:18 [notice] 23961#0: signal process started
2020/09/02 14:27:05 [notice] 24709#0: signal process started
2020/09/02 14:38:55 [notice] 24855#0: signal process started
2020/09/02 14:39:55 [notice] 24911#0: signal process started
2020/09/02 16:51:52 [notice] 25457#0: signal process started
2020/09/02 16:53:49 [notice] 25600#0: signal process started
2020/09/02 17:23:49 [notice] 25819#0: signal process started
2020/09/02 17:25:30 [notice] 25962#0: signal process started
2020/09/02 17:51:35 [notice] 26149#0: signal process started
2020/09/22 18:27:22 [notice] 2711#0: signal process started
2020/09/22 19:29:59 [notice] 2416#0: signal process started
2020/09/22 19:31:45 [notice] 1671#0: signal process started
2020/09/22 19:31:45 [alert] 1671#0: kill(1230, 15) failed (3: No such process)
2020/09/22 20:03:14 [notice] 3369#0: signal process started
2020/09/22 20:33:35 [notice] 4536#0: signal process started
作者: yxw886    时间: 2020-9-23 10:19
唐王李世民 发表于 2020-9-23 08:30
查看你的nginx配置或网站配置

用nginx -t检查过,没问题,但是手动用lnmp nginx start或者systemctl start nginx都可以启动,
作者: mjj不是我    时间: 2020-9-23 10:29
本帖最后由 mjj不是我 于 2020-9-23 10:30 编辑
yxw886 发表于 2020-9-23 10:11
这样是可以启动,但是每次开机不会自动启动nginx,但mysql、php可以


那把启动命令放入rc.local。就能开机自启了。
不同的linux系统,rc.local的位置可能不一样。
命令:
echo "/etc/init.d/nginx start " >>/etc/rc.local
作者: yxw886    时间: 2020-9-23 10:31
mjj不是我 发表于 2020-9-23 10:29
那把重启命令放入rc.local。就能开机自启了。
不同的linux系统,rc.local的位置可能不一样。
echo "/etc/ ...

这个方法试过,但是还是不会开机自启
echo "/etc/init.d/nginx start " >>/etc/rc.local
echo "/usr/local/nginx/sbin/nginx">>/etc/rc.local
这两个都试过也不行
作者: yxw886    时间: 2020-9-23 10:32
1819 发表于 2020-9-23 10:08
直接 看 nginx.conf, 看 error.log
如果没有配置错误日志, 自己再配置.
不看错误日志, 很难搞. ...

2020/09/02 11:44:39 [notice] 31091#0: signal process started
2020/09/02 11:46:25 [notice] 31233#0: signal process started
2020/09/02 13:41:18 [notice] 22336#0: signal process started
2020/09/02 13:55:23 [notice] 22939#0: signal process started
2020/09/02 14:04:24 [notice] 23231#0: signal process started
2020/09/02 14:06:18 [notice] 23961#0: signal process started
2020/09/02 14:27:05 [notice] 24709#0: signal process started
2020/09/02 14:38:55 [notice] 24855#0: signal process started
2020/09/02 14:39:55 [notice] 24911#0: signal process started
2020/09/02 16:51:52 [notice] 25457#0: signal process started
2020/09/02 16:53:49 [notice] 25600#0: signal process started
2020/09/02 17:23:49 [notice] 25819#0: signal process started
2020/09/02 17:25:30 [notice] 25962#0: signal process started
2020/09/02 17:51:35 [notice] 26149#0: signal process started
2020/09/22 18:27:22 [notice] 2711#0: signal process started
2020/09/22 19:29:59 [notice] 2416#0: signal process started
2020/09/22 19:31:45 [notice] 1671#0: signal process started
2020/09/22 19:31:45 [alert] 1671#0: kill(1230, 15) failed (3: No such process)
2020/09/22 20:03:14 [notice] 3369#0: signal process started
2020/09/22 20:33:35 [notice] 4536#0: signal process started
作者: mjj不是我    时间: 2020-9-23 12:40
yxw886 发表于 2020-9-23 10:31
这个方法试过,但是还是不会开机自启
echo "/etc/init.d/nginx start " >>/etc/rc.local
echo "/usr/loca ...

你确定你vps的rc.local文件在这个位置“/etc/" ?

先确定命令能够启动,然后确定rc.local的位置,赋予rc.local执行权限,重启vps。
#启动命令(哪个有效用哪个)
/etc/init.d/nginx start

lnmp nginx start
#找到rc.local的位置
find / -name rc.local
#授予执行权限
chmod +x  /路径/rc.local
在rc.local中添加,上面能够启动nginx的命令,重启vps。
echo "能启动的命令 " >>/路径/rc.local

作者: llyang    时间: 2020-9-23 13:10
2020/09/22 20:33:35 [notice] 4536#0: signal process started
这是最后一行,说明没有报错

我也不知道咋整了。
如果是我,重装蒜鸟
作者: yxw886    时间: 2020-9-24 10:48
llyang 发表于 2020-9-23 13:10
2020/09/22 20:33:35 [notice] 4536#0: signal process started
这是最后一行,说明没有报错

恩,找到很多地方都没找到原因,可能真的要重装了




欢迎光临 全球主机交流论坛 (https://fd.vvwvv.eu.org/) Powered by Discuz! X3.4