phpredis扩展安装

2023-06-08,,

redis高速缓存,有链表排序功能,效率相当高,对创建内存级的模块业务关系很有用

下载phpredis

git clone git://github.com/nicolasff/phpredis.git

wget http://download.csdn.net/detail/wkupaochuan/5100016

yum -y install php-devel 安装php-devel软件包,可以执行phpize命令

phpize生成编译文件,即可以调用./configure命令


tar zxvf phpredis.tar.gz

cd phpredis-2.2.4

/usr/local/php/bin/phpize     用phpize生成congfigure配置文件,类似初始化

./configure --with-php-config=/usr/bin/php-config

make && make install编译安装

    如果成功:在shell中输出生成的redis.so路径

在/etc/php.ini配置文件的extension_dir下面加入

    extension_dir="  "上面生成的路径

  extension=redis.so


验证:

重启php,重启web服务器,

/etc/init.d/php-fpm restart

service httpd restart


然后在phpinfo.php查看redis


连接到 redis 服务

<?php    //连接本地的 Redis 服务
   $redis = new Redis();
   $redis->connect('127.0.0.1', 6379);
   echo "Connection to server sucessfully";
         //查看服务是否运行
   echo "Server is running: "+ $redis->ping();?>

执行脚本,输出结果为:

Connection to server sucessfullyServer is running: PONG


《phpredis扩展安装.doc》

下载本文的Word格式文档,以方便收藏与打印。