# Centos安装Redis
# 下载源码
下载地址:http://redis.io/download (opens new window),下载最新稳定版

$ wget https://download.redis.io/releases/redis-6.0.9.tar.gz
$ tar xzf redis-6.0.9.tar.gz
$ cd redis-6.0.9
# 编译安装
$ make
$ make install
# 修改配置文件redis.conf
修改远程访问、后台启动和密码
- 隐藏
bind 127.0.0.1或修改为bind 0.0.0.0 - 修改
daemonize no为yes - 修改
requirepass <你的密码>
# 启动
$ ./src/redis-server ./redis.conf
# 使用systemd管理服务
在/etc/systemd/system目录下新建redis.service文件,写入以下内容
[Unit]
Description=redis-server
After=network.target
[Service]
Type=forking
ExecStart=${安装目录}/src/redis-server ${安装目录}/redis.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
刷新systemctl查看Redis状态
$ sudo systemctl daemon-reload
$ sudo systemctl status redis

设置开机启动
$ sudo systemctl enable redis.service

