【问题标题】:How to install memcache extension (php72, macos Catalina)如何安装 memcache 扩展(php72、macos Catalina)
【发布时间】:2020-01-17 09:33:38
【问题描述】:

我无法在 MacOs Catalina php 7.2 上安装 memcache(不是 memcached)扩展

checking for the location of zlib... configure: error: memcache support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located
ERROR: `/private/tmp/pear/temp/memcache/configure --with-php-config=/usr/local/opt/php@7.2/bin/php-config --enable-memcache-session=yes' failed

我试试

pecl install memcache --with-zlib-dir=/usr/local/Cellar/zlib/1.2.11/include/zlib.h

但是

Attempting to discover channel "--with-zlib-dir=/usr/local/Cellar/zlib/1.2.11/include"...
Attempting fallback to https instead of http on channel "--with-zlib-dir=/usr/local/Cellar/zlib/1.2.11/include"...
unknown channel "--with-zlib-dir=/usr/local/Cellar/zlib/1.2.11/include" in "--with-zlib-dir=/usr/local/Cellar/zlib/1.2.11/include/zlib.h"
invalid package name/package file "--with-zlib-dir=/usr/local/Cellar/zlib/1.2.11/include/zlib.h"

【问题讨论】:

    标签: macos memcached php-7.2 macos-catalina


    【解决方案1】:

    你已经接近了......你的路径不应该是头文件,而是目录。此外, pecl install 不会将脚本中的命令行参数传递给 ./configure 命令,因此您必须自己完成:

    pecl download memcache
    open memcache-4.0.5.2.tgz  
    cd memcache-4.0.5.2/memcache-4.0.5.2
    phpize
    ./configure --with-zlib-dir=/usr/local/Cellar/zlib/1.2.11
    make
    sudo make install
    

    【讨论】:

    • 如果需要重建,请务必在重新运行 phpize 之前进行清理:rm -fr build run-tests.php 否则您可能会收到“权限被拒绝”错误,因为文件在末尾设置为只读的 make && 安装。
    【解决方案2】:

    您可以使用环境变量PHP_ZLIB_DIR 告诉它zlib 在哪里。

    PHP_ZLIB_DIR=/usr/local/opt/zlib pecl install memcache
    

    【讨论】:

    • 对于 MacPorts 的 zlib,这个目录是“/opt/local”
    猜你喜欢
    • 2020-12-28
    • 2021-04-10
    • 1970-01-01
    • 1970-01-01
    • 2020-02-08
    • 1970-01-01
    • 1970-01-01
    • 2019-05-25
    • 2016-12-30
    相关资源
    最近更新 更多