1.安装LNMP各个组件
为了实验进度,这里就不演示安装LNMP了,想了解的可以看我之前博客,有演示安装LNMP的组件
2.安装redis服务
为了实验进度,这里就不演示安装redis了,想了解的可以看我之前博客,有演示安装LNMP的组件

3、安装 redis 扩展
(1)解压软件包
[root@localhost opt]# tar -zxvf redis-4.0.2.tgz
[root@localhost opt]# cd /opt/redis-4.0.2/
(2)运行 phpize 脚本的用途是动态安装 php 扩展模块
[root@localhost redis-4.0.2]# /usr/local/php/bin/phpize
(3)开始编译安装
./configure --with-php-config=/usr/local/php/bin/php-config --enable-redis
make && make install

4.修改php配置文件
vim /usr/local/php/lib/php.ini


5.测试链接
cd /usr/local/nginx/html/
[root@localhost html]# vim set.php
<?php
$redis = new redis();
$redis->connect('127.0.0.1', 6379);
$redis->set('test',"1111111111");
echo $redis->get('test');
?>

vim get.php
<?php
$redis = new redis();
$redis->connect('127.0.0.1', 6379);
$result = $redis->get('test');
var_dump($result);
?>

|