要查看真正的错误,您需要在不使用 brew 的情况下运行服务
我遇到了类似的问题,但是我无法启动 apache(httpd) 而不是 mongodb。
$ brew services start httpd
Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/501
/Users/john/Library/LaunchAgents/homebrew.mxcl.httpd.plist` exited with
5.
FAIL: 1
不幸的是,brew 没有向用户显示导致此错误的原因。起初,我尝试使用此线程中答案中的提示,但既没有重新安装 apache,也没有unload -w/load -w
帮助。我在酿造日志中也没有发现任何东西。我决定调查 apache 本身。为此,我在没有 brew 的情况下运行了 apache:
$ /opt/homebrew/Cellar/httpd/2.4.51/bin/apachectl start
httpd: Syntax error on line 66 of /opt/homebrew/etc/httpd/httpd.conf: Cannot load /opt/homebrew/Cellar/php@5.6/5.6.40_3/lib/httpd/modules/libphp5.so into server: dlopen(/opt/homebrew/Cellar/php@5.6/5.6.40_3/lib/httpd/modules/libphp5.so, 0x000A): tried: '/opt/homebrew/Cellar/php@5.6/5.6.40_3/lib/httpd/modules/libphp5.so' (no such file), '/usr/local/lib/libphp5.so' (no such file), '/usr/lib/libphp5.so' (no such file)
FAIL: 1
然后终于清楚了httpd服务没有启动的原因是什么。原来是php升级后,php版本变了,忘记在apache配置文件中写新的php版本了。我很快解决了这个问题,apache 启动了。