liunx php安装redis扩展的方法:1、查看redis版本;2、通过wget命令下载安装包并通过“tar zxf”解压安装包;3、执行“cd redis-4.0.8/src make”进行安装redis即可。
本教程操作环境:linux5.9.8系统、redis 4.0.8版、DELL G3电脑
linux 安装redis
linux 安装redis 非常简单,官网有介绍。
安装redis:
1.先查看redis版本,找到你想下载的版本:https://www.php.cn/link/136929a11b983e70981aaa17550ba1b2
2.安装redis
#2.1 下载安装包 wget http://download.redis.io/releases/redis-4.0.8.tar.gz #2.2 解压 tar zxf redis-4.0.8.tar.gz
1是下载的安装包,2是解压后的文件夹。 记住这个文件目录,我是在/root下面解压的,后面自启要用到这个redis目录里的文件
#2.3编译 cd redis-4.0.8/src make
#2.4 新建redis文件夹 mkdir /usr/local/redis
#2.5移动文件 cd redis-4.0.8/src mv redis-server /usr/local/redis mv redis-benchmark /usr/local/redis mv redis-cli /usr/local/redis cd ../ mv redis.conf /usr/local/redis
#2.6 启动redis cd /usr/local/redis ./redis-server #这个是以默认配置开启,配置文件redis.conf 开机自启要用到。
如上图所示,按配置文件启动,提示启动成功。
可能出现的警告:
WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
解决办法:
vim /etc/sysctl.conf
另起一行添加:
net.core.somaxconn = 511
保存后退出
然后:sysctl -p
WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
解决办法:
vim /etc/sysctl.conf
换行添加:
vm.overcommit_memory=1
保存后退出
sysctl -p
WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
解决办法:
vim /etc/rc.local
换行添加:
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then echo never > /sys/kernel/mm/transparent_hugepage/enabled fi
保存后退出
重启系统、重启服务器:
reboot
一般新服务器第一次安装redis然后启动都会有这三个警告。
#2.7 连接redis,进行测试 ./redis-cli set pandent 2018 get pandent
设置和获取都正常,说明redis已经安装成功啦。
推荐学习:《PHP视频教程》
以上是liunx php怎么安装redis扩展的详细内容。更多信息请关注PHP中文网其他相关文章!