[英]Install phpredis MAC OSX
Can anyone help me install php-redis in MAC OSX.谁能帮我在 MAC OSX 中安装 php-redis。
brew install php-redis
not working.不工作。
pecl install php-redis
also not working getting -也没有工作 -
invalid package name/package file "php-redis".
无效的 package 名称/包文件“php-redis”。
Homebrew Error:
自制错误:
git clone https://www.github.com/phpredis/phpredis.git
cd phpredis
phpize && ./configure && make && sudo make install
Add extension=redis.so
in your php.ini在 php.ini 中添加
extension=redis.so
brew services restart php@7.2
make test
You can check working or not你可以检查工作与否
php -r "if (new Redis() == true){ echo \"\r\n OK \r\n\"; }"
As of 2019, with homebrew php7.2 and up, pecl
is now installed by default alongside the php binaries.截至 2019 年,使用 homebrew php7.2 及更高版本,
pecl
现在默认安装在 php 二进制文件旁边。
To see this for yourself type which pecl
.要亲自查看,请键入
which pecl
。
Steps to install安装步骤
Check your version of redis, then find a suitable version of the extension here .检查你的 redis 版本,然后在这里找到合适的扩展版本。
If unfamiliar with pecl, type pecl
to see the options.如果不熟悉 pecl,请键入
pecl
以查看选项。
Issue pecl install redis-5.0.2
.发出
pecl install redis-5.0.2
。 (or your version). (或您的版本)。 Enter no to each question asked if you're not sure.
如果您不确定,请在询问的每个问题中输入“否”。
If that succeeds check the new file it created at: /usr/local/lib/php/pecl/20180731/redis.so
如果成功,请检查它在以下位置创建的新文件:
/usr/local/lib/php/pecl/20180731/redis.so
The install will have added extension="redis.so"
to top of your php ini.安装将在您的 php ini 顶部添加
extension="redis.so"
。 Check that by opening the file /usr/local/etc/php/7.3/php.ini
.通过打开文件
/usr/local/etc/php/7.3/php.ini
来检查。 (assuming you're on 7.3 there) (假设您在那里使用 7.3)
brew services restart php
. brew services restart php
。
php -i | grep Redis
Redis Support => enabled
Redis Version => 5.0.2
This is what I just did in September 2019 and it works for me.这就是我刚刚在 2019 年 9 月所做的,它对我有用。
If what mwal wrote above doesn't work (please try his/her answer first),如果上面写的mwal不起作用(请先尝试他/她的答案),
first, try to uninstall first (if you have it but broken):首先,尝试先卸载(如果你有它但坏了):
sudo pecl uninstall redis
and after that run:之后运行:
sudo pecl install redis
After that, ini the php.ini, use full path for the extension.之后, ini php.ini,使用扩展的完整路径。
Mine was /usr/local/Cellar/php@7.3/7.3.21/pecl/20180731/redis.so (assuming you are using php@7.3)我的是/usr/local/Cellar/php@7.3/7.3.21/pecl/20180731/redis.so(假设您使用的是php@7.3)
so at the top of my php.ini file is like this:所以在我的 php.ini 文件的顶部是这样的:
extension="/usr/local/Cellar/php@7.3/7.3.21/pecl/20180731/redis.so"
Here are steps to use pickle
, for PHP >= 7.3 (tested with 8.1):以下是使用
pickle
的步骤,适用于 PHP >= 7.3(使用 8.1 测试):
brew install pickle
pickle install redis
php -i|grep php.ini
php -i|grep php.ini
extension=redis
.extension=redis
。 Preferable at Dynamic Extensions
section.Dynamic Extensions
部分。Bonus奖金
If you use VS Code, to enable intellisense / auto complete, at Preference
-> paste intelephense.stubs
at Search setting box -> Add Item -> select redis
.如果您使用 VS Code,要启用 intellisense / 自动完成,请在
Preference
-> paste intelephense.stubs
at Search setting box -> Add Item -> select redis
。
If you got the following error,如果出现以下错误,
Please make sure the PHP Redis extension is installed and enabled
请确保已安装并启用 PHP Redis 扩展
despite doing everything in the verified answer above, try valet restart
.尽管在上面经过验证的答案中做了所有事情,请尝试
valet restart
。 It worked for me它对我有用
I have tried all these solutions but didn't work for me for a while so I tried this link https://developer.redis.com/develop/php/ from the original docs and it works as charm我已经尝试了所有这些解决方案,但有一段时间没有为我工作,所以我尝试了原始文档中的链接https://developer.redis.com/develop/php/并且它很有魅力
If someone gets an error during sudo pecl install redis
如果有人在
sudo pecl install redis
期间出错
Warning: mkdir(): File exists in System.php on line 294
警告:mkdir():文件存在于第 294 行的 System.php 中
PHP Warning: mkdir(): File exists in /opt/homebrew/Cellar/-----/pear/System.php on line 294
PHP 警告:mkdir():文件存在于 /opt/homebrew/Cellar/-----/pear/System.php 第 294 行
that means you need to create the broken directory manually.这意味着您需要手动创建损坏的目录。 Try to create the directory...
尝试创建目录...
pecl config-get ext_dir | pbcopy
mkdir -p {paste clipboard value}
# in my case, it was
mkdir -p /opt/homebrew/lib/php/pecl/20200930
Now try to install any pecl extensions.现在尝试安装任何pecl扩展。
sudo pecl install redis
After installing any extension, restart php安装任何扩展后,重新启动php
brew services restart php
Happy coding:)快乐的编码:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.