1、以安装redis5.0.8为例
下载安装包:http://redis.io
安装非常简单!
root@centos6 ~]#yum install gcc #需要先安装GCC,如果已安装请忽略
[root@centos6 ~]wget http://download.redis.io/releases/redis-5.0.8.tar.gz
[root@centos6 ~]tar zxvf redis-5.0.8.tar.gz -C /usr/local #解压
[root@centos6 ~]mv /usr/local/redis-5.0.8 /usr/local/redis #重命名
[root@centos6 ~]cd /usr/local/redis #进入解压后的文件夹
[root@centos6 redis]make #编译
没错,已经安装完毕了!
2、修改配置文件
[root@centos6 ~]# vi /usr/local/redis/redis.conf #修改配置文件
protected-mode no # 关闭保护模式
daemonize yes # 守护进程模式开启
#bind 127.0.0.1 # 绑定IP按需修改
port 6379 # 端口按需修改
3、运行并检查端口
[root@centos6 redis]#./src/redis-server redis.conf #启动服务命令
[root@centos6 redis]#netstat -tunpl | grep 6379 #查看6379端口是否占用
4、开放防火墙端口
[root@centos6 ~]#/sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT #开放6379端口
[root@centos6 ~]#/etc/rc.d/init.d/iptables save #保存配置
[root@centos6 ~]#/etc/rc.d/init.d/iptables restart #重启服务
[root@centos6 ~]#/etc/init.d/iptables status #查看端口是否已经开放
5、设置开机启动
[root@centos6 ~]#vi /etc/rc.local
添加一行
/usr/local/redis/src/redis-server /usr/local/redis/redis.conf
6、创建快捷命令
cp /usr/local/redis/src/redis-cli /usr/bin/