Centos7.x Redis快速安装脚本
下面是一个 Centos7.x 系统下安装 Redis 并设置开机自启以及远程访问的 shell 脚本:
#!/bin/bash
# Update the system
# yum update -y
# --下载fedora的epel仓库
yum install epel-release -y
# Install redis
yum install redis -y
# Enable Redis to start on boot
systemctl enable redis
# Start Redis
systemctl start redis
# Allow remote connections to Redis
sed -i 's/bind 127.0.0.1/bind 0.0.0.0/' /etc/redis.conf
# Restart Redis to apply changes
systemctl restart redis
# Check the status of Redis
systemctl status redis
使用方法:
- 使用 root 用户登录服务器
- 创建一个名为 redis_install.sh 的文件
- 将上面的脚本复制到 redis_install.sh 文件中
- 执行以下命令:
chmod +x redis_install.sh
./redis_install.sh
该脚本将安装 Redis,并在系统启动时自动启动,并且可以远程访问 Redis。