php安装redis扩展

前言:php安装redis扩展有很多办法,自己下载,编译,但是最简单得办法是利用apache的pecl

直接去github下载安装
https://github.com/phpredis/phpredis/

省事的办法
http://pecl.php.net/package/redis

cd /Applications/XAMPP/bin

sudo ./pecl install redis

安装redis的过程中,会提示询问两个问题,默认答案是no,直接回车即可。

configuration option "php_ini" is not set to php.ini location
You should add "extension=redis.so" to php.ini
 
install ok: channel://pecl.php.net/redis-4.1.1

php.net 官方提供得最新版本也是redis4.1.1

<?php 
   //Connecting to Redis server on localhost 
   $redis = new Redis(); 
   $redis->connect('java-er.com', 6379); 
   echo "Connection to server sucessfully"; 
   //check whether server is running or not 
   echo "<br>Server is running: ".$redis->ping();
 
   echo "<br> Stored string in redis: " .$redis->get("foo"); 
 
 
?>
Connection to server sucessfully
Server is running: +PONG
Stored string in redis: bar

当php5.6 遇到高版本的redis 2019-12-07补充记录
php redis 安装

redis软件版本为最新的redis 5.0.7
默认的php安装办法

# whereis pecl

pecl: /usr/bin/pecl

输入

pecl install redis
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
pecl/redis requires PHP (version >= 7.0.0, version <= 7.9.99), installed version is 5.6.36
No valid packages found
install failed
pecl install redis-2.2.8

搞定 –20191206

安装完毕重启动php-fpm

pecl install redis-3.1.2 后来发现这个版本也能安装,但是这个版本立即搞死了服务器。立即删除 pecl unstall redis


This entry was posted in PHP and tagged , . Bookmark the permalink.
月小升QQ 2651044202, 技术交流QQ群 178491360
首发地址:月小升博客https://java-er.com/blog/php-install-redis-extension/
无特殊说明,文章均为月小升原创,欢迎转载,转载请注明本文地址,谢谢
您的评论是我写作的动力.
2020.03.24 评论已经全局关闭,有事加QQ聊天