如何为 php 7 安装 redis 扩展
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46955555/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install redis extension for php 7
提问by Prashant G Patil
Referred this link https://anton.logvinenko.name/en/blog/how-to-install-redis-and-redis-php-client.html
引用此链接https://anton.logvinenko.name/en/blog/how-to-install-redis-and-redis-php-client.html
And done following steps
并完成以下步骤
PhpRedis for PHP 7 (Skip it if you have different PHP version)
PhpRedis for PHP 7(如果你有不同的 PHP 版本,请跳过它)
Install required package
安装所需的包
apt-get install php7.0-dev
Download PhpRedis
下载 PHPRedis
cd /tmp
wget https://github.com/phpredis/phpredis/archive/php7.zip -O phpredis.zip
But, https://github.com/phpredis/phpredis/archive/php7.zipfile not found for installation.
但是,找不到用于安装的https://github.com/phpredis/phpredis/archive/php7.zip文件。
采纳答案by Iurii Drozdov
Try to use this url https://github.com/phpredis/phpredis/archive/3.1.4.zip
尝试使用这个网址https://github.com/phpredis/phpredis/archive/3.1.4.zip
wget https://github.com/phpredis/phpredis/archive/3.1.4.zip -O phpredis.zip
回答by schellingerht
Yesterday, I installed Redis on my Vagrant box (/etc/php/7.0
):
昨天,我在我的 Vagrant box ( /etc/php/7.0
)上安装了 Redis :
sudo pecl install redis
sudo service php7.0-fpm restart
sudo pecl install redis
sudo service php7.0-fpm restart
(optional: run php -m
for listing the php modules).
(可选:运行php -m
以列出 php 模块)。
Now, you can use the Redis
class in your php code.
现在,您可以Redis
在 php 代码中使用该类。
回答by Amir Fo
I found a repositoryfrom ubuntu:
我从 ubuntu找到了一个存储库:
sudo apt-get install php-redis
- Restart apache after installation.
- 安装后重启apache。
回答by Farzie Karamat
I just ran the command below for Cent os 7
我刚刚为 Cent os 7 运行了以下命令
yum install php-redis
Resolved my issue and i added the config in php.ini manualy
解决了我的问题,我在 php.ini 中手动添加了配置
You should add "extension=redis.so" to php.ini
您应该将“extension=redis.so”添加到 php.ini
回答by Jeremy Quick
This GitHub is a great resource for MAMP users.
For Mac Users:
对于 Mac 用户:
- Download
redis.so
from the appropriate subdirectory of the repobased on major and minor version number X.Y (following semver). - Move the file to
/Applications/MAMP/bin/php/phpX.Y.X/lib/php/extensions/no-debug-non-zts-xxxxxxxx
- Add
extension=redis.so
to the end of php.ini
- 根据主要和次要版本号 XY(在 semver 之后)
redis.so
从repo的相应子目录下载。 - 将文件移动到
/Applications/MAMP/bin/php/phpX.Y.X/lib/php/extensions/no-debug-non-zts-xxxxxxxx
- 添加
extension=redis.so
到php.ini的末尾
Updated resource above, previously listed this
上面更新了资源,之前列出了这个