redis 原生安装
一、环境配置
shell
# 如果没有gcc,需要安装
wget http://download.redis.io/releases/redis-5.0.14.tar.gz二、下载
shell
# 官网下载安装包,这里是5.0.14版本
wget http://download.redis.io/releases/redis-5.0.14.tar.gz三、解压安装
shell
# 解压
tar -zxvf redis-5.0.14.tar.gz
cd redis-5.0.14
# 这行没试过
./configure --prefix=/usr/local/redis
make && make install四、配置、启动
1、拷贝配置文件
shell
# -s 禁止登陆 -d 登陆默认目录
cd ~/redis-5.0.14
# 如果指定了安装位置,就复制到这里
cp redis.conf /usr/local/redis/bin/
cp redis.conf /usr/local/bin/2、修改配置(可选)
shell
/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.conf3、启动 redis
shell
# 启动命令
./redis-server /usr/local/bin/redis.conf &五、配置远程访问
1、开启防火墙端口
shell
firewall-cmd --zone=public --add-port=6379/tcp --permanent
firewall-cmd --reload六、注册成服务并开机自启
shell
todo