php - 无法在 macOS Sierra 上使用 Homebrew 安装 PHP 7

标签 php homebrew macos-sierra

我正在尝试设置 Laravel 的 Valet,作为依赖项,它需要 PHP 7。当我尝试使用 Homebrew 安装 PHP 7 时,出现以下错误:

Configuring SAPI modules
checking for Apache 2.0 handler-module support via DSO through APXS... 

Sorry, I cannot run apxs.  Possible reasons follow:

1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)

The output of /usr/sbin/apxs follows:
apxs:Error: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/apr-1-config not found!.

configure: error: Aborting

READ THIS: https://git.io/brew-troubleshooting
If reporting this issue please do so at (not Homebrew/brew):
  https://github.com/Homebrew/homebrew-php/issues

These open issues may also help:
php70-dbase  https://github.com/Homebrew/homebrew-php/issues/3508
php70-intl not found https://github.com/Homebrew/homebrew-php/issues/3591
php70-opcache install issue https://github.com/Homebrew/homebrew-php/issues/3586
Problem installing php70-mcrypt, php70-opcache, php70-xdebug on El Capitan https://github.com/Homebrew/homebrew-php/issues/3587
Add php70-zmq formula https://github.com/Homebrew/homebrew-php/pull/3474
Problem installing homebrew/php/php70-imagick https://github.com/Homebrew/homebrew-php/issues/3571
Install PHP70: Incompatible library version https://github.com/Homebrew/homebrew-php/issues/3444
brew install php70-redis https://github.com/Homebrew/homebrew-php/issues/2762
Allow --enable-redis-igbinary for php70-redis https://github.com/Homebrew/homebrew-php/pull/3473
Add head formula for php70-uploadprogress https://github.com/Homebrew/homebrew-php/pull/3178

这是全新安装的 MacOS Sierra(实际版本,不是测试版)和全新安装的 Homebrew(已更新)。我已经安装、运行并同意 Xcode 许可协议(protocol)。

我不知道这些错误是什么意思。我该如何修复它们?

最佳答案

是的,我已经弄明白了。我在下面发布了成功安装所需组件的步骤,以防其他人偶然发现此问题:

1).确保 Homebrew 是最新的:

brew update

2).通过确保安装了 Xcode 然后在终端中键入以下内容来修复 PHP 7 错误:

brew install apr apr-util
sudo mkdir -p /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/
sudo ln -s /usr/local/opt/apr/bin/apr-1-config /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/
sudo ln -s /usr/local/opt/apr-util/bin/apu-1-config /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/

3).运行以下命令(否则 PHP 安装会提示缺少 libz):

xcode-select --install

4).您现在可以使用 Homebrew 安装 PHP 7:

brew install homebrew/php/php70

关于php - 无法在 macOS Sierra 上使用 Homebrew 安装 PHP 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39626301/

相关文章:

bash - 如何使用 brew 更新应用程序列表?

Python、Brew 和 MySQLdb

php - 无法可靠地确定 MacBook 服务器的完全限定域名

php - 如何删除wordpress数据库中的现有表

php - 我的观看计数器有什么问题

PHP 扩展类使子级继承相同的静态属性

linux - 在 Mac OS X 的命令行参数中,vmd 不使用文件名打开

php - 如何将 css 类分配给 echo $output

ruby-on-rails - 运行 bundle install 时出现 sqlite3 错误

macos - 如何在Interface Builder中使用自定义NSView?