php - 无法在 Mac Big Sur 上安装 PHP yaml 扩展
问题描述
运行pecl install yaml
错误configure: error: ‘yaml.h’ header not found
我通过 Homebrewbrew install php@7.4
和 libyaml 一起安装了 PHP 7.4.14,brew install libyaml
但仍然看到同样的错误。
我还尝试重新安装 xcode 开发工具,以及使用 sudo 运行 pecl,但每次仍然出现相同的错误。下面是 pecl 的完整输出。
Starting to download yaml-2.2.1.tgz (40,977 bytes)
............done: 40,977 bytes
8 source files, building
running: phpize
Configuring for:
PHP Api Version: 20190902
Zend Module Api No: 20190902
Zend Extension Api No: 320190902
Please provide the prefix of libyaml installation [autodetect] :
building in /private/tmp/pear/temp/pear-build-mattfergusonRvLour/yaml-2.2.1
running: /private/tmp/pear/temp/yaml/configure --with-php-config=/usr/local/opt/php@7.4/bin/php-config --with-yaml
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-apple-darwin20.2.0
checking host system type... x86_64-apple-darwin20.2.0
checking target system type... x86_64-apple-darwin20.2.0
checking for PHP prefix... /usr/local/Cellar/php@7.4/7.4.14
checking for PHP includes... -I/usr/local/Cellar/php@7.4/7.4.14/include/php -I/usr/local/Cellar/php@7.4/7.4.14/include/php/main -I/usr/local/Cellar/php@7.4/7.4.14/include/php/TSRM -I/usr/local/Cellar/php@7.4/7.4.14/include/php/Zend -I/usr/local/Cellar/php@7.4/7.4.14/include/php/ext -I/usr/local/Cellar/php@7.4/7.4.14/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/Cellar/php@7.4/7.4.14/pecl/20190902
checking for PHP installed headers prefix... /usr/local/Cellar/php@7.4/7.4.14/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking whether to enable LibYAML suppot... yes, shared
checking for yaml headers... found in /usr/local
checking for ANSI C header files... no
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... no
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... no
checking for stdint.h... no
checking for unistd.h... yes
checking yaml.h usability... no
checking yaml.h presence... no
checking for yaml.h... no
configure: error: ‘yaml.h’ header not found
ERROR: `/private/tmp/pear/temp/yaml/configure --with-php-config=/usr/local/opt/php@7.4/bin/php-config --with-yaml’ failed
解决方案
也许你应该检查一下。
Please provide the prefix of libyaml installation [autodetect] :
今天我得到了同样的东西。我尝试输入 libyaml 前缀解决。
这是步骤:
步骤1
$brew uninstall libyaml
Uninstalling /opt/homebrew/Cellar/libyaml/0.2.5... (10 files, 369.7KB)
第2步
$brew install libyaml
==> Downloading https://github.com/yaml/libyaml/archive/0.2.5.tar.gz
Already downloaded: /Users/**/Library/Caches/Homebrew/downloads/688fdcea5b88140cb83d1f72e3a77fa76b6560f0d66eabcea7d54cf9f06d5e72--libyaml-0.2.5.tar.gz
==> ./bootstrap
==> ./configure --prefix=/opt/homebrew/Cellar/libyaml/0.2.5
==> make install
/opt/homebrew/Cellar/libyaml/0.2.5: 10 files, 369.7KB, built in 12 seconds
step3 复制 step2 中的前缀。
#In this case,It's
/opt/homebrew/Cellar/libyaml/0.2.5
第4步
$sudo pecl install yaml
Password:
downloading yaml-2.2.1.tgz ...
Starting to download yaml-2.2.1.tgz (40,977 bytes)
............done: 40,977 bytes
8 source files, building
running: phpize
Configuring for:
PHP Api Version: 20160303
Zend Module Api No: 20160303
Zend Extension Api No: 320160303
Please provide the prefix of libyaml installation [autodetect] :
step5 粘贴您在 step3 中复制的信息,按回车键。
Please provide the prefix of libyaml installation [autodetect] : /opt/homebrew/Cellar/libyaml/0.2.5
终于成功了。
推荐阅读
- python - 如何合并数据框的行
- node.js - 从 Axios 调用中正确抛出错误
- python - 只有当它们等于某个值或它们在该值之间的一行中时才保留列值(熊猫)
- python - 使用访问令牌从文件元数据获取的下载 url 不适用于 Google Drive
- asp.net-mvc - 通过 IIS 部署网站:无法访问网站
- python - 使用电子邮件 python 库获取附件名称不起作用
- android - 如何在 Long 中设置 MediaStore openOutputStream 偏移量?
- amazon-web-services - AWS Device Farm - 计划运行 - 错误
- javascript - 在边界框更改位置和显示时加载 MarkerClusters
- javascript - JS Datables jquery在一列中排序具有多个值