故障-nginx启动失败
描述:在⽤saltstack给 minion 安装 nginx 服务时提⽰ nginx 服务下载成功,但是启动失败。
----------
ID: nginx-systemctl
Function: service.running
Name: nginx
Result: False
Comment: Service nginx failed to start
Started: 09:32:48.221250
Duration: 3317.741 ms
Changes:
-
---------
nginx:
False
然后就去minion 端查看了⼀下端⼝是否开启  netstat -lntup  发现没有nginx  进程也没有
然后⼿动起了⼀下提⽰如下报错:
[root@salt1-minion ~]# systemctl start nginx
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe"for details.意思就是Nginx服务起不来了,然后查看⼀下状态吧, systemctl status nginx
[root@salt1-minion ~]# systemctl status nginx
● 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 Wed 2018-11-2109:33:38 CST; 15s ago
Process: 1475 ExecStart=/usr/sbin/nginx (code=exited, status=1/FAILURE)
Process: 1472 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 1471 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Nov 21 09:33:37 salt1-minion nginx[1475]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Nov 21 09:33:37 salt1-minion nginx[1475]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Nov 2109:33:37 salt1-minion nginx[1475]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Nov 2109:33:38 salt1-minion nginx[1475]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Nov 2109:33:38 salt1-minion nginx[1475]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Nov 2109:33:38 salt1-minion systemd[1]: nginx.service: control process exited, code=exited status=1
Nov 2109:33:38 salt1-minion nginx[1475]: nginx: [emerg] still could not bind()
Nov 2109:33:38 salt1-minion systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Nov 2109:33:38 salt1-minion systemd[1]: Unit nginx.service entered failed state.
Nov 2109:33:38 salt1-minion systemd[1]: nginx.service failed.
从报错信息中会看到,Address already in use ,意思就是地址已经被使⽤了。当时发现了⾃⼰的失误,原来是之前下载过httpd ,也是80端⼝。
那就去修改⼀下nginx 的配置⽂件吧,修改端⼝,去到 /etc/f⽂件⾥,把端⼝修改为443
server {
listen      443 default_server;
listen      [::]:443 default_server;
然后重新启动服务
[root@salt1-minion nginx]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address          Foreign Address        State      PID/Program name
tcp        000.0.0.0:220.0.0.0:*              LISTEN      914/sshd
tcp        00127.0.0.1:250.0.0.0:*              LISTEN      1001/master
tcp        000.0.0.0:443 0.0.0.0:*              LISTEN      1507/nginx: master
exitedtcp6      00 :::80                  :::*                    LISTEN      919/httpd
tcp6      00 :::22                  :::*                    LISTEN      914/sshd
tcp6      00 ::1:25                  :::*                    LISTEN      1001/master
tcp6      00 :::443                  :::*                    LISTEN      1507/nginx: master
[root@salt1-minion nginx]# systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2018-11-2109:35:20 CST; 9s ago
Process: 1505 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
最后⽹页访问主机加端⼝测试,没有问题。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。