首页 > 解决方案 > Mac OS Big Sur - Homebrew Apache - 48)地址已在使用中:AH00072:make_sock:无法绑定到地址 0.0.0.0:8080

问题描述

我在 Mac OS Big Sur 上遇到 Apache 的问题。操作系统更新后,Apache(使用 Brew)不再工作。所以我决定卸载httpd公式。然后测试的是 Apache 的预装版本,它确实有效。

  1. 所以我已经停止了预装的 Apachesudo apachectl stop
  2. 卸载的发射器sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
  3. 更新了自制软件
    • brew update
    • brew doctor
    • brew upgrade
  4. 再次安装httpd brew install httpd(安装成功)
  5. 启动httpdsudo brew services start httpd

但是检查状态sudo brew services list我可以看到 httpd 服务有 status error。当我尝试使用启动 apache 时sudo apachectl start收到错误消息:

(48)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:8080
no listening sockets available, shutting down
AH00015: Unable to open logs

我已经检查过 8080 端口上是否有其他东西在运行,lsof -i TCP:8080但事实并非如此。

我检查了使用的是哪个 Apache ( which apachectl),它似乎是正确的 ( /usr/local/bin/apachectl)

无论我尝试使用哪个端口,总是会出现地址已在使用中的错误。

有谁知道如何解决这个问题?

标签: macosapachehomebrewmacos-big-sur

解决方案


我面临着同样的问题。看来绑定INADDR_ANY (0.0.0.0)失败了。

为了规避绑定错误,我更改/usr/local/etc/httpd/httpd.conf了以下行:

Listen 8080

至:

Listen 127.0.0.1:8080

之后,我可以使用以下命令启动 apache 而不会出现绑定错误:

sudo apachectl -k start

推荐阅读