mac 上nginx的错误 nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)

来源:互联网 发布:什么移动电源 知乎 编辑:程序博客网 时间:2024/06/06 20:12

今天在mac上运行nginx,发现一直报错:

nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use) 

查到的解决方法是nginx自己占用了80端口,又把自己block住,只要killall -9 nginx 即可。

试了下,发现根本找不到nginx进程。

使用ps -ef | grep nginx 也同样找不到。

于是查看是哪些进程占用了80端口:lsof -i:80

把对应的程序都关闭掉,发现依然不行。

通过浏览器访问http://localhost发现得到的页面根本没有在nginx的任何地方定义过。也就是说当前服务器启动的并不是nginx。

用chrome的开发者工具查看了下响应消息,响应消息的powdered-by字段赫然写着apache。

猛然想起来前不久为了测试一个php项目,启用了mac自带的apache服务器。

于是果断 sudo apachectl stop终止掉apache服务。问题解决。

顺带提一句,当nginx -s reload命令出现:nginx: [error] open()"/opt/local/var/run/nginx/nginx.pid" failed (2: No such file ordirectory)错误的话,解决办法:

nginx -c /opt/local/etc/nginx/nginx.conf(your/path/to/config/file)

 
原创粉丝点击