1、redis 下载 https://redis.io/download
wget http://download.redis.io/releases/redis-3.2.6.tar.gz
2、解压缩
tar xzf redis-3.2.6.tar.gz
3、进入解压后的文件目录
cd redis-3.2.6
4、redis安装相对简单,直接编译即可
make
编译后在目录下会有一个产生一个新的“src”目录
5、创建存储redis文件目录
mkdir -p /usr/local/redis
6、进入src目录,复制redis-server redis-cli到新建立的文件夹
cp ./redis-server /usr/local/redis/
cp ./redis-cli /usr/local/redis/
7、复制redis的配置文件
cd ..
cp redis.conf /usr/local/redis/
8、编辑配置文件
cd /usr/local/redis/
vim redis.conf
改 daemonize 为 yes 后台运行
如果需要redis配置认证密码
vim redis.conf
#搜索 requirepass,设置密码
requirepass youpwd
9、添加开机启动服务
vim /etc/systemd/system/redis-server.service
[Unit]
Description=The redis-server Process Manager
After=syslog.target network.target
[Service]
Type=simple
PIDFile=/var/run/redis_6379.pid
## ExecStart=/usr/local/redis/redis-server /usr/local/redis/redis.conf
## ExecStart=/software/redis-6.0.10/src/redis-server --protected-mode no
## /software/redis-6.0.10/src/redis-server /software/redis-6.0.10/redis.conf --protected-mode no
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID
[Install]
WantedBy=multi-user.target
10、设置开机启动
systemctl daemon-reload
systemctl start redis-server.service
systemctl enable redis-server.service
11、检查是否安装成功
12、创建redis命令软连接
ln -s /usr/local/redis/redis-cli /usr/bin/redis
13、测试redis
完成安装!