在centos7刚安装nginx 后启动报错:
[root@localhost html]# systemctl restart nginx
Job for nginx.service failed because the control process exited with error code. See “systemctl status nginx.service” and “journalctl -xe” for details.
[root@localhost html]# systemctl status nginx.service
● 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 Tue 2019-04-09 21:00:29 CST; 4min 48s ago
Process: 68521 ExecStart=/usr/sbin/nginx (code=exited, status=1/FAILURE)
Process: 68518 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 68516 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Apr 09 21:00:28 localhost nginx[68521]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Apr 09 21:00:28 localhost nginx[68521]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Apr 09 21:00:28 localhost nginx[68521]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Apr 09 21:00:29 localhost nginx[68521]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Apr 09 21:00:29 localhost nginx[68521]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Apr 09 21:00:29 localhost nginx[68521]: nginx: [emerg] still could not bind()
Apr 09 21:00:29 localhost systemd[1]: nginx.service: control process exited, code=exited status=1
Apr 09 21:00:29 localhost systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Apr 09 21:00:29 localhost systemd[1]: Unit nginx.service entered failed state.
Apr 09 21:00:29 localhost systemd[1]: nginx.service failed.
ss -antp 显示:
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 127.0.0.1:9000 *:* users:(("php-fpm",pid=44167,fd=0),("php-fpm",pid=44166,fd=0),("php-fpm",pid=44165,fd=0),("php-fpm",pid=44164,fd=0),("php-fpm",pid=44163,fd=0),("php-fpm",pid=44162,fd=6))
LISTEN 0 128 *:111 *:* users:(("rpcbind",pid=781,fd=8))
LISTEN 0 5 192.168.122.1:53 *:* users:(("dnsmasq",pid=1467,fd=6))
LISTEN 0 128 *:22 *:* users:(("sshd",pid=51519,fd=3))
LISTEN 0 128 127.0.0.1:631 *:* users:(("cupsd",pid=1081,fd=12))
LISTEN 0 128 127.0.0.1:6010 *:* users:(("sshd",pid=58561,fd=9))
LISTEN 0 128 127.0.0.1:6011 *:* users:(("sshd",pid=64134,fd=9))
ESTAB 0 52 10.0.112.237:22 10.0.112.250:49778 users:(("sshd",pid=58561,fd=3))
ESTAB 0 0 10.0.112.237:22 10.0.112.250:57851 users:(("sshd",pid=64134,fd=3))
LISTEN 0 80 :::3306 :::* users:(("mysqld",pid=42610,fd=25))
LISTEN 0 128 :::111 :::* users:(("rpcbind",pid=781,fd=11))
LISTEN 0 128 :::80 :::* users:(("httpd",pid=44221,fd=4),("httpd",pid=44220,fd=4),("httpd",pid=44219,fd=4),("httpd",pid=44218,fd=4),("httpd",pid=44217,fd=4),("httpd",pid=44216,fd=4),("httpd",pid=41364,fd=4),("httpd",pid=41363,fd=4),("httpd",pid=41362,fd=4),("httpd",pid=41361,fd=4),("httpd",pid=41360,fd=4))
LISTEN 0 32 :::21 :::* users:(("vsftpd",pid=5154,fd=4))
LISTEN 0 128 :::22 :::* users:(("sshd",pid=51519,fd=4))
LISTEN 0 128 ::1:631 :::* users:(("cupsd",pid=1081,fd=11))
LISTEN 0 128 ::1:6010 :::* users:(("sshd",pid=58561,fd=8))
LISTEN 0 128 ::1:6011 :::* users:(("sshd",pid=64134,fd=8))
最后killall httpd 就好了
[root@localhost html]# killall httpd
[root@localhost html]# systemctl restart nginx
[root@localhost html]# systemctl status nginx
```
[root@localhost html]# systemctl restart nginx
[root@localhost html]# 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 Tue 2019-04-09 21:07:44 CST; 15s ago
Process: 68631 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 68629 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 68627 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 68634 (nginx)
Tasks: 3
CGroup: /system.slice/nginx.service
├─68634 nginx: master process /usr/sbin/nginx
├─68635 nginx: worker process
└─68636 nginx: worker process
Apr 09 21:07:44 localhost systemd[1]: Starting The nginx HTTP and reverse proxy server...
Apr 09 21:07:44 localhost nginx[68629]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Apr 09 21:07:44 localhost nginx[68629]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Apr 09 21:07:44 localhost systemd[1]: Failed to read PID from file /run/nginx.pid: Invalid argument
Apr 09 21:07:44 localhost systemd[1]: Started The nginx HTTP and reverse proxy server.