安装:

wget http://download.redis.io/releases/redis-5.0.4.tar.gz
yum install -y gcc g++

tar zxvf redis-5.0.4.tar.gz
mkdir -p /usr/local/redis/{etc,data}
cd redis-5.0.4

#编译
make
#安装
make install PREFIX=/usr/local/redis
#复制配置文件
cp redis.conf /usr/local/redis/etc

修改配置文件

# vim /usr/local/redis/etc/redis.conf
#外网可访问
protected-mode yes
#bind 127.0.0.1

#修改AOF及RBD存放路径
dir /usr/local/redis/data
#修改log存放路径
logfile /usr/local/redis/data

#把redis服务添加至systemctl管理

# vim /lib/systemd/system/redis.service

[Unit]
Description=redis.server
After=network.target

[Service]
Type=forking
PIDFILE=/var/run/redis_6379.pid
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
ExecRepload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

修改后即可使用systemctl start/stop redis.service 来管理 开机自启动: systemctl enable redis.service