1. 程式人生 > >centos啟動Nginx提示nginx: [emerg] still could not bind()

centos啟動Nginx提示nginx: [emerg] still could not bind()

centos7中啟動Nginx: /usr/local/nginx/sbin/nginx,提示以下內容

[[email protected] ~]# /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埠),然後根據埠檢視端口占用情況

[[email protected] ~]# netstat -ntlp|grep 80  
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      7043/nginx: worker

使用kill命令殺死佔用程序,之後重新啟動Nginx

kill -9 7043