pecl install memcache 在 OS X Yosemite 和 "memcache support requires ZLIB" 上失败

pecl install memcache fails on OS X Yosemite with "memcache support requires ZLIB"

我正在尝试在 OS X Yosemite 上使用 XAMPP 执行 pecl install memcache,但找不到 zlib,并产生此错误:

checking for the location of ZLIB... no
checking for the location of zlib... configure: error: memcache support requires ZLIB.

Use --with-zlib-dir= to specify prefix where ZLIB include and library are located

ERROR: `/private/tmp/pear/temp/memcache/configure --enable-memcache-session=yes' failed

如何安装 zlib 以便此 pecl install memcache 能够成功?

brew install zlib

如果您还没有这样做

接下来找到 zlib 头文件:

locate zlib.h

您可能会发现有几个选项可供选择。

/Applications/Xcode.app/Contents/Developer/Platforms/ etc

/usr/local/Cellar/zlib/1.2.8/include/zlib.h

我尽可能使用 brew,所以我选择了 brew 版本:

brew install php55-memcached --with-zlib-dir=/usr/local/Cellar/zlib/1.2.8/include/zlib.h

我假设将此标志传递给 pecl 会得到相同的结果。

我在使用另一个扩展时遇到了同样的问题 (SPX)

checking for zlib header... checking for zlib location... configure: error: spx support requires ZLIB. Use --with-zlib-dir=<DIR> to specify the prefix where ZLIB headers and library are located

当 运行 ./configure 使用 --with-zlib-dir 标志时,我确实修复了它。确保安装了 zlib (brew install zlib)。

phpize

# replace "./configure" with:
./configure --with-zlib-dir=/usr/local/Cellar/zlib/1.2.11
# or "--with-zlib-dir=/opt/homebrew/Cellar/zlib/1.2.11" for Apple silicon

make
sudo make install