php - 如何在 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的步骤是什么?
解决方案
我在同一个问题上苦苦挣扎,我的问题通过以下步骤解决。
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
推荐阅读
- jquery - jquery 可排序脚本 - 获取拖动项 id
- javascript - 在浏览器中启动 Ubuntu/Linux 上的 JNLP 文件(Chrome(67) /Mozilla)
- c# - 如何从 EF Core 中的父实体中删除子实体?
- json - 使用 alamofire 在 Swift 上解析 Json
- mysql - Mysql选择查询3个表
- android - startActivityForResult 没有回调(onActivityResult)
- python - 如何通过更改 yield SplashRequest 的代码将 URL 从 A 的方法传递给 B?(Scrapy + Splash with Python & Dcoker)
- scala - Scala:在通用类后面隐藏两个类
- node.js - Node /Express,如何将 bodyParser 配置为仅在某些路由上使用 raw
- json - 动态创建某种类型的结构并将 JSON 解组到该实例中