【问题标题】:nginx configuration issue, ports already in usenginx 配置问题,端口已在使用中
【发布时间】:2015-06-03 07:29:24
【问题描述】:

我最近迁移到 Mac OSX Yosemite 10.10 并关注了this tutorial

为了设置我的机器,经过多次打嗝后,我终于设法达到了一个点,即我发现由于 nginx 端口问题而只发生了一个问题。

如果我这样做

sudo nginx

我明白了

nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (48: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:306 failed (48: Address already in use)
nginx: [emerg] still could not bind()

这意味着 443 和 306 端口正在其他地方使用

当我这样做时

sudo lsof -i:443

我明白了

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 548 root 13u IPv4 0xce9cf564560ec22b 0t0 TCP *:https (LISTEN)
nginx 549 nobody 13u IPv4 0xce9cf564560ec22b 0t0 TCP *:https (LISTEN)

sudo lsof -i:306 类似

我明白了

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 548 root 14u IPv4 0xce9cf564560ed3cb 0t0 TCP *:306 (LISTEN)
nginx 549 nobody 14u IPv4 0xce9cf564560ed3cb 0t0 TCP *:306 (LISTEN)

现在如果 nginx 已经在使用这些端口了,怎么会声称 Address 已经在使用中了

当我在浏览器中运行我的应用程序时说 abc.dev.com

我没有得到服务器的响应,有时浏览器只是告诉我

连接已超时 abc.dev.com 的服务器响应时间过长。

如果我这样做 curl http://abc.dev.com 我会得到

curl: (7) 连接abc.dev.com 80端口失败:操作超时

如果我这样做了

nginx.start

我明白了:

/Library/LaunchDaemons/homebrew.mxcl.nginx.plist:操作已在进行中

如果我这样做::

nginx.stop //它有效,我认为它停止了

如果我这样做:

nginx.restart

我明白了:

/Library/LaunchDaemons/homebrew.mxcl.nginx.plist:找不到指定的服务

我已经没有想法了,想不出任何可能导致这种情况的原因。任何想法都受到高度赞赏...

感谢您的帮助。

【问题讨论】:

    标签: php mysql macos curl nginx


    【解决方案1】:

    您在此处链接的指南的作者。看起来你设法让 Nginx 在没有适当的 LaunchDaemon 的情况下运行。

    你能确定,当你输入“nginx.stop”时,进程真的停止了吗? (ps aux)。

    关于“nginx.restart”的最后一个错误:这很正常,因为您之前已经使用“nginx.stop”停止了服务。所以重启(实际上是:stop && start)会出现错误,因为它试图停止一个已经停止的服务。

    无论如何,由于您的问题几乎与指南相关/相关,因此我不确定 StackOverflow 是否适合进行此讨论。让我们更好地继续在指南的评论部分。

    【讨论】:

    • 我看不到我的评论。如果你能批准我的评论,我会跟进。
    • @Mike 它已经被批准了。这是direct link
    • 谢谢好友,我必须说很棒的教程,但我回复了你的评论
    猜你喜欢
    • 2014-09-20
    • 2021-08-20
    • 1970-01-01
    • 2014-12-02
    • 1970-01-01
    • 2014-06-03
    • 2019-08-17
    • 2018-12-31
    相关资源
    最近更新 更多