【问题标题】:How to install php-redis extension on mac os 10.13?如何在 mac os 10.13 上安装 php-redis 扩展?
【发布时间】:2018-12-20 18:48:14
【问题描述】:

这几天我正在尝试安装 php-redis 扩展。

尝试使用 brew 并得到这个...

$ brew install php71-redis
Error: No available formula with the name "php71-redis" 
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.

尝试用 PECL 安装并得到这个...

    $ sudo pecl install redis
    downloading redis-4.1.0.tgz ...
    Starting to download redis-4.1.0.tgz (220,774 bytes)
    ..............................................done: 220,774 bytes
    25 source files, building
    running: phpize
    Configuring for:
    PHP Api Version:         20160303
    Zend Module Api No:      20160303
    Zend Extension Api No:   320160303
   ************

   ************
    checking whether to enable igbinary serializer support... yes
    checking whether to enable lzf compression... yes
    checking use system liblzf... no
    checking for igbinary includes... configure: error: Cannot find igbinary.h
    ERROR: `/private/tmp/pear/install/redis/configure --with-php-config=/usr/bin/php-config --enable-redis-igbinary=нуы --enable-redis-lzf=yes' failed

最后尝试安装 igbinary.h ....

$ sudo pecl install igbinary
downloading igbinary-2.0.7.tgz ...
Starting to download igbinary-2.0.7.tgz (73,523 bytes)

   ************

   ************


Build process completed successfully
Installing '/usr/include/php/ext/igbinary/igbinary.h'
ERROR: failed to mkdir /usr/include/php/ext/igbinary

【问题讨论】:

  • 我认为您尝试创建/usr/include/php/ext/igbinary 可能会违反系统完整性保护,请参阅support.apple.com/en-us/ht204899 也许您可以以某种方式只为自己安装在您的HOME 目录中而不是在所有用户的系统目录中?抱歉,我不太了解pecl

标签: macos redis homebrew pecl


【解决方案1】:

我刚刚在 Mac OS 10.13 上执行此操作(我仍在使用 High Sierra)。

使用 homebrew php7.2 及更高版本,pecl 现在默认安装在 php 二进制文件旁边。

要亲自查看,请输入which pecl

安装步骤

  1. 检查你的redis版本,然后找到合适的扩展here版本。

  2. 如果不熟悉 pecl,请输入 pecl 以查看选项。

  3. 问题pecl install redis 5.0.2。 (或您的版本)。如果您不确定,请在询问的每个问题中输入“否”。

  4. 如果成功,请检查它在以下位置创建的新文件:/usr/local/lib/php/pecl/20180731/redis.so

  5. 安装程序会将extension="redis.so" 添加到您的 php ini 顶部。 通过打开文件/usr/local/etc/php/7.3/php.ini 进行检查。 (假设你在那里使用 7.3)

  6. brew services restart php.

  7. php -i | grep Redis

Redis Support => enabled
Redis Version => 5.0.2

这是在 2019 年 9 月做的,它对我有用。

【讨论】:

    【解决方案2】:

    为此,请尝试在 OSx (Mac) 上禁用 csrutil:

    1. 重新启动您的 Mac
    2. Mac 启动时,输入 Command + R 直到进入恢复模式
    3. 在恢复模式下,转到实用程序并选择终端
    4. 在终端输入csrutil disable
    5. 重启你的mac并通过pecl重做redis安装

    应该可以。

    【讨论】:

    猜你喜欢
    • 2018-10-19
    • 2019-08-03
    • 2018-11-01
    • 2010-11-29
    • 1970-01-01
    • 2012-10-15
    • 2018-03-30
    • 2010-12-24
    • 1970-01-01
    相关资源
    最近更新 更多