一、PHP客户端
1、官方提供了几款PHP客户端,包括amphp/redis、phpredis、Predis、Rediska。推荐使用官方推荐的两款客户端,phpredis、Predis
2、phpredis是一个二进制版本的PHP客户端,效率要比Predis高。这个版本支持作为Session的Handler。这个扩展的优点在于无需加载任何外部文件,使用比较方便。
3、Predis是一个灵活和特性完备(PHP>5.3)的支持Redis的PHP客户端。优点就是无须安装PHP扩展包,直接加载使用即可,在保证PHP版本在5.3版本之上的情况下,即使迁移服务器也不受影响。
4、缺点就是性能相较于phpredis较差。

二、phpredis客户端的安装
1、phpredis的github地址:https://github.com/phpredis/phpredis
直接git clone https://github.com/phpredis/phpredis.git
2、cd phpredis
3、phpize
./configure [--enable-redis-igbinary] [--enable-redis-msgpack] [--enable-redis-lzf [--with-liblzf[=DIR]]]
make && make install

官方对configure几个参数的说明
If you would like phpredis to serialize your data using the igbinary library, run configure with --enable-redis-igbinary. If you would like to use the msgpack serializer, run configure with --enable-redis-msgpack (note: Requires php-msgpack >= 2.0.3) The extension also may compress data before sending it to Redis server, if you run configure with --enable-redis-lzf. If you want to use lzf library pre-installed into your system use --with-liblzf configuration option to specify the path where to search files. make install copies redis.so to an appropriate location, but you still need to enable the module in the PHP config file. To do so, either edit your php.ini or add a redis.ini file in /etc/php5/conf.d with the following contents: extension=redis.so.

如果不使用参数可以直接./configure
执行以后会报一个configure: error: Cannot find php-config. Please use --with-php-config=PATH错误,没有找到php-config
所以需要使用./configure --with-php-config=PATH,其中PATH是你php-config命令所在的目录

4、看到如下图所示信息说明扩展包文件已经搭好,并且放在/usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/目录下

5、需要将redis.so加载到php.ini中
vim /usr/local/php/etc/php.ini

6、重启php-fpm和nginx
lnmp php-fpm restart
lnmp nginx restart
7、使用php -m命令查看

说明安装成功

8、打开phpinfo

9、测试写入数据

1)新建redisdemo.php
2)写入如下代码

$redis = new Redis();

$a = $redis->connect("主机IP",6379);

var_dump($a);
//打印结果:bool(true) 说明链接成功
$redis->set("test","test");

执行以后查看服务器

最新文章

  1. Idea 快捷键
  2. jquery源码中的(function(window, undefined){})(window)【转】
  3. 一般处理程序获取WEB窗体创建的验证码需要实现session相关接口
  4. ACE 6.2.0 AIX 编译
  5. [转载]MongoDB学习(二):数据类型和基本概念
  6. HTTP 500 - 内部服务器错误
  7. 支付宝开通海外退税 阿里腾讯暗战跨境O2O_21世纪网
  8. asp.net(C#)利用QRCode生成二维码---.NET菜鸟的成长之路
  9. sqlserver查询数据库中有多少个表
  10. springboot 简单使用 activemq 接收消息
  11. 代码的重构(Refactor-Extract)
  12. 【webssh】网页上的SSH终端
  13. 网络编程Socket知识点回复
  14. mysql的导入导出工具mysqldump命令详解
  15. #C++初学记录(ACM试题1)
  16. ubuntu安装谷歌拼音输入法
  17. [笔试]CVTE 2019提前批 Windows应用开发笔试
  18. 分布式ID方案有哪些以及各自的优势
  19. Highcharts 气泡图
  20. oracle数据库分页原理

热门文章

  1. 干货 | 10分钟带你掌握branch and price(分支定价)算法超详细原理解析
  2. OpenFOAM计算结果转换到CFD-Post当中处理
  3. 2015-2016-2《Java程序设计》团队博客1
  4. 在IDEA上对SpringBoot项目配置Devtools实现热部署
  5. PyTorch 实战:计算 Wasserstein 距离
  6. shell case例子
  7. [LINUX] 快速回收连接
  8. Docker打包部署前端项目与负载均衡
  9. chrome安装react-devtools开发工具插件
  10. 某表中字段值存在多个Gid逗号分开 取值拆分每个gid SQL多个逗号隔开的取值