记一次Nginx启动时提示nginx: [emerg] still could not bind()

今儿一大早,天气好好,心情很好,寻思着更几篇文章,好家伙,网站先是打不开, 启动Nginx: /usr/local/nginx/sbin/nginx 时,提示以下内容:

[root@host ~]# /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端口),然后根据端口查看端口占用情况

[root@v157040 ~]# netstat -ntlp|grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1916/nginx: master  

使用kill命令杀死占用进程,之后重新启动Nginx

kill 1916

然后再次进入网站,提示我 “数据库连接出错”

重启数据库就OKK啦!!!


评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据