有人可以帮我在MAC OSX上安装php-redis吗。
brew install php-redis
不能工作。
pecl install php-redis
还不能工作,得到 -
无效的包名/包文件“php-redis”。
Homebrew 错误:
有人可以帮我在MAC OSX上安装php-redis吗。
brew install php-redis
不能工作。
pecl install php-redis
还不能工作,得到 -
无效的包名/包文件“php-redis”。
Homebrew 错误:
git clone https://www.github.com/phpredis/phpredis.git
cd phpredis
phpize && ./configure && make && sudo make install
在您的php.ini文件中添加extension=redis.so
brew services restart php@7.2
make test
您可以检查是否工作
php -r "if (new Redis() == true){ echo \"\r\n OK \r\n\"; }"
从2019年开始,使用自制的php7.2及以上版本,pecl
将默认与php二进制文件一起安装。
要查看自己的情况,请键入which pecl
。
安装步骤
检查您的redis版本,然后在此处找到一个适合的扩展版本。
如果对pecl不熟悉,请键入pecl
以查看选项。
输入pecl install redis-5.0.2
(或您的版本)。如果不确定,请每个问题都选择no。
如果安装成功,请检查它创建的新文件:/usr/local/lib/php/pecl/20180731/redis.so
安装将在您的php ini顶部添加extension="redis.so"
。
通过打开文件/usr/local/etc/php/7.3/php.ini
来检查它。
(假设您使用的是7.3)
brew services restart php
。
php -i | grep Redis
Redis Support => enabled
Redis Version => 5.0.2
这是我在2019年9月刚刚做过的,对我很有效。
pecl uninstall redis
,然后 pecl install redis
。 - Evgeniy Maynagashevpecl install redis
在没有 sudo
的情况下对我来说无法工作:https://superuser.com/a/1707730/79629 - andrewtweberredis.so
安装在不同的位置。 pecl install redis-x
输出如下。在将php.ini文件中的顶部行更新为正确的位置后,扩展正确加载了。 - user3703155sudo pecl uninstall redis
之后运行:
sudo pecl install redis
此后,在php.ini中,使用扩展的完整路径。
我的路径是/usr/local/Cellar/php@7.3/7.3.21/pecl/20180731/redis.so(假设您正在使用php@7.3)
所以我的php.ini文件顶部看起来像这样:
extension="/usr/local/Cellar/php@7.3/7.3.21/pecl/20180731/redis.so"
sudo pecl install redis
期间出现错误
这意味着您需要手动创建损坏的目录。 尝试手动创建该目录...警告:System.php的第294行中已存在mkdir()文件
PHP警告:/opt/homebrew/Cellar/-----/pear/System.php的第294行中已存在mkdir()文件
pecl config-get ext_dir | pbcopy
mkdir -p {paste clipboard value}
# in my case, it was
mkdir -p /opt/homebrew/lib/php/pecl/20200930
现在尝试安装任何 pecl 扩展。
sudo pecl install redis
brew services restart php
编程愉快 :)
pickle
的步骤,适用于PHP >= 7.3(已在8.1中测试):
brew install pickle
pickle install redis
php -i|grep php.ini
查找您的php.ini位置。Dynamic Extensions
部分插入extension=redis
。Preference
中粘贴intelephense.stubs
到搜索设置框中,然后添加项目并选择redis
。我尝试了所有这些解决方案,但是在一段时间内对我没有用,所以我从原始文档中尝试了这个链接https://developer.redis.com/develop/php/,它完美地解决了我的问题。
尽管已经按照上面验证过的答案做了一切,还是无法解决问题,那么请尝试执行Please make sure the PHP Redis extension is installed and enabled
valet restart
命令。这个方法对我很有效。
pecl install redis
安装 Redis,但是 "not working" 这个描述还比较模糊。如果你能提供遇到的错误或困难,我们或许可以帮助解决 Homebrew 的问题。 - ceejayozpecl help
是一个有用的命令,可以帮助你发现pecl search
命令。例如:pecl search edis
可以给你想要的答案。 - YvesLeBorgphp-redis
了,所以你不能再使用brew install php-redis
或者brew options php-redis
。你需要使用pecl
来安装 Redis 并让 PHP 知道它的存在。 - Mark Setchell