# redis 原生安装

# 一、环境配置

# 如果没有gcc,需要安装
wget http://download.redis.io/releases/redis-5.0.14.tar.gz
1
2

# 二、下载

# 官网下载安装包,这里是5.0.14版本
wget http://download.redis.io/releases/redis-5.0.14.tar.gz
1
2

# 三、解压安装

# 解压
tar -zxvf redis-5.0.14.tar.gz
cd redis-5.0.14
# 这行没试过
./configure --prefix=/usr/local/redis
make && make install
1
2
3
4
5
6

# 四、配置、启动

# 1、拷贝配置文件

# -s 禁止登陆 -d 登陆默认目录
cd ~/redis-5.0.14
# 如果指定了安装位置,就复制到这里
cp redis.conf /usr/local/redis/bin/
cp redis.conf /usr/local/bin/
1
2
3
4
5

# 2、修改配置(可选)

/usr/local/bin/redis.conf
#注释掉原有的配置
sed "s/^bind .*/#&/" /usr/local/bin/redis.conf  -i
#加入新配置
grep -q '^#bind ' /usr/local/bin/redis.conf && sed -i '/^#bind .*/a\bind 127.0.0.1' /usr/local/bin/redis.conf || echo 'bind 127.0.0.1' >> /usr/local/bin/redis.conf
1
2
3
4
5

# 3、启动 redis

# 启动命令
./redis-server /usr/local/bin/redis.conf &
1
2

# 五、配置远程访问

# 1、开启防火墙端口

firewall-cmd --zone=public --add-port=6379/tcp --permanent
firewall-cmd --reload
1
2

# 六、注册成服务并开机自启

todo
1