首页 > 解决方案 > 如何在 macos high sierra 上使用 homebrew 或 pecl 在 php 7.0 上安装 php-redis?

问题描述

试图在我的 high sierra apache 上安装 php 7.0 的 redis 扩展。

brew install php-redis- 不工作。

brew install php@7.0-redis- 不工作。

brew install php70-redis- 不工作。

google google google - Homebrew 是错误的方法,使用 pecl,他们说。

pecl search redis显示:

redis 4.0.2 (stable) 4.0.2 PHP extension for interfacing with Redis

所以pecl install redis

pecl/redis is already installed and is the same as the released version 4.0.2 install failed

唔。这是正确的。我已经引用了ini文件:

cat /usr/local/etc/php/7.0/conf.d/ext-redis.ini

[redis] extension="/usr/local/lib/php/pecl/20160303/redis.so"

sudo 服务 apachectl -k 重启

检查 phpinfo() - 没有提到 redis,但它确实声明它正在加载 ext-redis.ini 文件。

肯定不会加载,因为如果我尝试在 php 页面上使用它,我会得到

Fatal error: Uncaught phpFastCache\Exceptions\phpFastCacheDriverCheckException: Redis is not installed or is misconfigured, cannot continue.

2018年macos上php连接redis的步骤是什么?

标签: phpmacosredishomebrewpecl

解决方案


我在同一个问题上苦苦挣扎,我的问题通过以下步骤解决。

git clone https://www.github.com/phpredis/phpredis.git
cd phpredis
phpize && ./configure && make && sudo make install

添加extension=redis.so你的 php.ini

我的 php.ini 路径是这个你可以通过 phpinfo();/usr/local/etc/php/7.0/php.ini 找到 php.ini 路径重启你的 php

brew services restart php@7.0

运行make test。Redis 支持已启用。现在您可以在 phpinfo() 中查看在此处输入图像描述


推荐阅读