CentOS 7.7 安装redis-5.0.7
参考文献:https://blog.csdn.net/lingfeian/article/details/93755467
下载安装包并解压,移动到安装目录
wget http://download.redis.io/releases/redis-5.0.7.tar.gz
tar -zxvf redis-5.0.7.tar.gz
sudo mv redis-5.0.7 /usr/local/
编译并安装
需要进入root账户 su root,编译需要gcc 安装 yum install gcc
cd /usr/local/redis-5.0.7/
make PREFIX=/usr/local/redis install
复制配置文件
cp /usr/local/redis-5.0.7/redis.conf /usr/local/redis/bin/
检查是否能够运行
cd /usr/local/redis/bin
./redis-server ./redis.conf &
配置后台启动,添加外网地址
cd /usr/local/redis/bin
vi redis.conf
将daemonize no 改为yes
添加 bind 192.168.31.100
设置开机自启动
# 新建如下文件
vim /etc/systemd/system/redisd.service
#复制下面内容
[Unit]
Description=redis-server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf #改成自己的
PrivateTmp=true
[Install]
WantedBy=multi-user.target
重载服务
systemctl daemon-reload
systemctl start redisd.service
systemctl status redisd.service
systemctl enable redisd.service