macos - 如何在 mac os 10.13 上安装 php-redis 扩展?

标签 macos redis homebrew pecl

这几天我一直在尝试安装 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

最佳答案

我刚刚在 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 服务重启 php

  7. php -i | grep Redis

Redis Support => enabled
Redis Version => 5.0.2

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

关于macos - 如何在 mac os 10.13 上安装 php-redis 扩展?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51307311/

相关文章:

ruby-on-rails - 在 Rails 中使用哈希数组进行分页?

mono - 如何使用 Homebrew 软件在 Mac 上安装 mono 5.0.x?

python - 在 Homebrew Python 2.7 安装中升级 pip 的问题

c++ - OSX Catalina 上的 C++ 和 gem 问题

macos - Xcode 应用程序,带或不带垃圾收集,

python - 如何使用 scrapy-redis 管道?

redis - 如何从多个 RDB 文件中恢复 Redis

ruby - Homebrew 程序(Mac): cannot install libksba or dependency libgpg-error

macos - "config"脚本存在于系统或 Homebrew 目录之外

windows - 如何将 Cocoa/Mac 应用程序移植到 Windows?