centos7安装redis

我的php版本是7.1,所以我下载的是4.0.9,版本要和redis版本对应,不然不执行
1.安装

 wget http://download.redis.io/releases/redis-4.0.9.tar.gz
 tar -zxvf redis-4.0.9.tar.gz
 mv redis-4.0.9 /usr/local/redis
 cd /usr/local/redis
 make 
 make install

make完后,在redis-4.0.9目录下会出现编译后的redis服务程序redis-server,还有用于测试的客户端程序redis-cli,两个程序位于安装目录 src 目录下:

启动redis服务测试

cd src
./redis-server

ctrl+c退出

2.以后台进程方式启动redis
1.修改redis.conf文件

daemonize no

修改为

daemonize yes

3、设置redis开机自启动

cp /usr/local/redis/utils/redis_init_script /etc/init.d/redisd

修改redisd

vim /etc/init.d/redisd

修改 CONF="/usr/local/redis/redis.conf"

并在第一行加入如下两行注释,保存退出

# chkconfig:   2345 90 10
# description:  Redis is a persistent key-value database

执行命令,成功

chkconfig redisd on

现在可以直接已服务的形式启动和关闭redis了

启动:

service redisd start
  Starting Redis server...
  23830:C 02 Apr 18:08:44.569 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
  23830:C 02 Apr 18:08:44.569 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=23830, just started
  23830:C 02 Apr 18:08:44.569 # Configuration loaded

停止:

service redisd stop
  Stopping ...
  Redis stopped

以上借鉴自
https://www.cnblogs.com/zuidongfeng/p/8032505.html
https://www.cnblogs.com/haozhen/p/9851712.html
·

你可能感兴趣的:(centos7安装redis)