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


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

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

*

  

About Me

静水流深,水滴石穿