Linux-CentOS6.9下安装Redis 4.0.10以及安装phpredis扩展

Linux-CentOS下安装Redis4.0.10

sudo -s
下载、解压、编译 Redis 4.0.10
cd /data0/software/
wget http://download.redis.io/releases/redis-4.0.10.tar.gz
tar xzf redis-4.0.10.tar.gz
cd redis-4.0.10
make
安装 Redis 4.0.10
cd ./src
make install PREFIX=/usr/local/redis

cp ../redis.conf /usr/local/redis/conf/redis.conf
启动 Redis 4.0.10
/usr/local/redis/bin/redis-server /usr/local/redis/conf/redis.conf
客户端连接 Redis 4.0.10
/usr/local/redis/bin/redis-cli
> set key value
OK
> get key
"value"
> exit
停止 Redis 4.0.10
/usr/local/redis/bin/redis-cli shutdown
或者
pkill redis-server
配置 Redis 4.0.10
vi /usr/local/redis/conf/redis.conf
daemonize yes   # 后台运行

详细配置参考 https://www.cnblogs.com/gaoyuechen/p/7801652.html

开机启动 Redis 4.0.10
vi /etc/rc.local
/usr/local/redis/bin/redis-server /usr/local/redis/conf/redis.conf
安装phpredis扩展

下载phpredis扩展并安装扩展

cd /data0/software
wget https://github.com/phpredis/phpredis/archive/4.1.0.tar.gz
mv 4.1.0.tar.gz phpredis.4.1.0.tar.gz
tar zxvf phpredis.4.1.0.tar.gz
cd phpredis-4.1.0/

/usr/local/php72/bin/phpize  # 用phpize生成configure配置文件
./configure --with-php-config=/usr/local/php7/bin/php-config # 配置
make            # 编译
make install    # 安装

安装完成之后,出现下面的安装路径

Installing shared extensions:     /usr/local/php72/lib/php/extensions/no-debug-zts-20170718/

配置php.ini

vi /usr/local/php72/etc/php.ini
extension=redis.so  # 添加redis.so

# 保存退出

# 重启php-fpm
service php-fpm72 configtest
service php-fpm72 reload

phpinfo() 看到redis相关信息,安装php扩展成功

参考

http://www.redis.cn/download.html
http://www.runoob.com/redis/redis-install.html
https://www.cnblogs.com/codersay/p/4301677.html
https://www.cnblogs.com/gaoyuechen/p/7801652.html

phpredis扩展安装参考
https://www.cnblogs.com/doseoer/p/6161110.html
https://blog.csdn.net/gb4215287/article/details/75655003
https://segmentfault.com/a/1190000012505240

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页