场景描述: linux 上安装redis ,并且PHP环境安装redis扩展
安装redis
1.获取redis 资源
wget http://download.redis.io/releases/redis-4.0.14.tar.gz
2.解压
tar xzvf redis-4.0.14.tar.gz
3.安装 -编译
cd redis-4.0.14
make
cd src
make install PREFIX=/usr/local/redis
4.移动配置文件 方便管理
比如 /home/redisconf
makdir /home/redisconf
mv redis.conf /home/redisconf
mv redis-cli /home/redisconf
mv redis-benchmark /home/redisconf
mv redis-server /home/redisconf
5.配置redis为后台启动
vim home/redisconf/redis.conf
//将daemonize no 改成daemonize yes
6.增加开机运行脚本
vim /etc/rc.local
增加启动脚
redis-server /home/redisconf/redis.conf
7.开启redis
redis-server /home/redisconf/redis.conf
PHP上安装redis 扩展
1.获取redis扩展资源
wget https://github.com/nicolasff/phpredis/archive/4.0.1.tar.gz
2.解压
tar zxvf 4.0.1.tar.gz //生成对应的 phpredis-4.0.1
3.用phpize生成configure配置文件
cd phpredis-2.2.4
/usr/local/php/bin/phpize
4. #配置
./configure --with-php-config=/usr/local/php/bin/php-config
5.编译
make
6.安装
make install
安装完成之后,出现下面的安装路径
/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
7.配置php .ini文件
vi /usr/local/php/etc/php.ini
加入 extension=redis.so
8.重启服务 生效
sudo service nginx restart
sudo /etc/init.d/php-fpm restart