yum install gcc


wget http://download.redis.io/releases/redis-5.0.7.tar.gz


cp redis-5.0.7.tar.gz  /usr/local


cd /usr/local


tar -zxvf redis-5.0.7.tar.gz


cd redis-5.0.7


make


make  install 



cp /usr/local/redis-5.0.7/redis.conf   /usr/local/etc/


设置后台启动


vi /usr/local/etc/redis.conf


    daemonize yes


设置redis服务器开机自动启动


vi /lib/systemd/system/redis.service


[Unit]

Description=The redis-server Process Manager

Documentation=https://redis.io/

After=network.target

 

[Service]

Type=forking

ExecStart=/usr/local/bin/redis-server /usr/local/etc/redis.conf

ExecStop=/usr/local/bin/redis-cli shutdown

PrivateTmp=true

[Install]

WantedBy=multi-user.target



systemctl enable redis


systemctl start redis


systemctl status redis


redis-cli


127.0.0.1:6379>info server



这个是用户启动项,意思是只有这个用户登陆的时候才启动:

/usr/lib/systemd/system/


这个是系统开机启动项,意思是开机就启动,不管哪个用户登录:

/lib/systemd/system/


查看所有的开机启动项:

systemctl list-unit-files |grep enabled