Blog - wingsico

在腾讯云制作镜像的时候强制关闭了服务器,后面外网就访问不了服务器了。记录一下解决过程

解决过程

一开始以为是文件丢失了,后面用vnc上去看了之后文件都还在,然后我就又重启了好几遍,网页还是访问不了,于是我先放在一边。 第二天再看了一下,发现二级域名下的资源可以访问,但主域名的无法访问,显示502 bad gateway。 于是觉得应该是nginx的问题,试图重启nginx

1
systemctl reload nginx

失败,报了个错:

1
Job for nginx.service invalid.

难道是没有开启?

1
systemctl start nginx

。。报了个更长的错

1
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

根据它的提示我试了一下

1
systemctl status nginx.service

得到如下的信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2018-01-12 20:33:08 CST; 27s ago
Process: 2702 ExecStart=/usr/sbin/nginx (code=exited, status=1/FAILURE)
Process: 2698 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 2697 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)

Jan 12 20:33:06 VM_48_13_centos nginx[2702]: nginx: [emerg] bind() to [::]:80 failed (98: ...e)
Jan 12 20:33:07 VM_48_13_centos nginx[2702]: nginx: [emerg] bind() to 0.0.0.0:80 failed (9...e)
Jan 12 20:33:07 VM_48_13_centos nginx[2702]: nginx: [emerg] bind() to [::]:80 failed (98: ...e)
Jan 12 20:33:07 VM_48_13_centos nginx[2702]: nginx: [emerg] bind() to 0.0.0.0:80 failed (9...e)
Jan 12 20:33:07 VM_48_13_centos nginx[2702]: nginx: [emerg] bind() to [::]:80 failed (98: ...e)
Jan 12 20:33:08 VM_48_13_centos nginx[2702]: nginx: [emerg] still could not bind()
Jan 12 20:33:08 VM_48_13_centos systemd[1]: nginx.service: control process exited, code=e...s=1
Jan 12 20:33:08 VM_48_13_centos systemd[1]: Failed to start The nginx HTTP and reverse pr...er.
Jan 12 20:33:08 VM_48_13_centos systemd[1]: Unit nginx.service entered failed state.
Jan 12 20:33:08 VM_48_13_centos systemd[1]: nginx.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

不是很看得懂,看到一堆failed和disabled. 先看一下nginx的进程。

1
2
3
4
ps -ef | grep  nginx
root 2516 1 0 Jan12 ? 00:00:00 nginx: master process nginx
nginx 2517 2516 0 Jan12 ? 00:00:00 nginx: worker process
root 5308 4831 0 09:04 pts/1 00:00:00 grep --color=auto nginx

把nginx进程关闭

1
pkill -9 nginx

再次启动nginx

1
systemctl start nginx

嗯,没有消息就是最好的消息,没有报错了,启动成功。但这个时候主域名还是访问不了,想到主域名上面放的是博客,博客是wordpress驱动的,用的php,想到可能是php挂死了,那重启一下php-fpm吧。

1
2
killall php-fpm
./opt/php56/sbin/php-fpm

再访问一下主域名,ok,博客成功显示。

 评论