如何在 MacOS 11 Big Sur 上安装 brew httpd?

How can I install brew httpd on MacOS 11 Big Sur?

我已经将 macOS 版本升级到 11 Big Sur 并且无法使用 brew 的 apache 而不是内置版本。

我做了什么:

sudo apachectl stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null

brew intall httpd

当我尝试启动已安装的 httpd 时,它说 apache 已启动

==> Successfully started httpd (label: homebrew.mxcl.httpd)

但是当我 运行 brew services 命令时,我看到 httpd 没有启动(并且 http://localhost:8080 没有工作)。

sergeylyskov@MacBook-Pro-Sergey ~ % brew services            
Name          Status  User         Plist
httpd         error   sergeylyskov /Users/sergeylyskov/Library/LaunchAgents/homebrew.mxcl.httpd.plist
php@7.3       stopped              
php@7.4       stopped              
postgresql@12 stopped              

P.S。我想使用 brew 的版本,因为似乎在 apache 中构建不能正确使用 php 模块(它不在 phpinfo() 中显示 xdebug 和 imagick 扩展)

有什么建议吗?

我尝试卸载然后重新安装 httpd,但最初并没有奏效。当您卸载时,brew 不会删除 /usr/local/etc/httpd 配置目录(这是明智的,因为您可能在那里配置了很多东西但没有备份)。但是,这些配置文件很可能已过时(或自定义),使其与最新版本的 httpd 不兼容,从而导致失败。所以我做了以下事情:

brew services stop httpd
brew uninstall httpd
mv /usr/local/etc/httpd /usr/local/etc/httpd-old
brew install httpd 
brew services start httpd

这 运行 使用新的配置文件又搞定了;我现在可以将任何特定的配置详细信息从 httpd-old 复制到新的 httpd 目录中。

另请注意:默认情况下,httpd 从 /usr/local/var/www 提供服务。这个目录不受卸载-重新安装过程的影响,所以只有你的配置文件需要重新做。