centos7中启动Nginx: /usr/local/nginx/sbin/nginx,提示以下内容
[root@localhost nginx-1.8.0]# /usr/local/nginx/sbin/nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
说明端口被占用,解决办法:
根据Nginx配置文件查看配置的端口(本文中使用的是80端口),然后根据端口查看端口占用情况
使用netstat -ntlp|grep 80 指令
[root@localhost nginx-1.8.0]# netstat -ntlp|grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 11903/nginx: master
[root@localhost nginx-1.8.0]# netstat -ntlp|grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 11904/nginx: worker
然后使用以下指令关闭,然后再重启nginx就可以了
[root@localhost nginx-1.8.0]# kill -9 11903