1. 下载
http://download.redis.io/redis-stable.tar.gz
2. 安装
cd /usr/local/src
tar -zxvf redis-stable.tar.gz #解压
mv redis-stable /usr/local/redis #移动文件到安装目录
cd /usr/local/redis #进入安装目录
make #编译
make install #安装
3. 修改redis.conf
ln -s /usr/local/redis/redis.conf /etc/redis.conf #添加配置文件软连接
vi /etc/redis.conf #编辑
daemonize yes #设置后台启动redis
:wq! #保存退出
4.修改/etc/init.d/redis
# chkconfig: 2345 90 10
# description: Redis is a persistent key-value database
PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
REDIS_CLI=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis.pid
CONF="/etc/redis.conf"
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
5. 添加开机启动
chmod 755 /etc/init.d/redis #添加脚本执行权限
chkconfig --add redis #添加开启启动
chkconfig --level 2345 redis on #设置启动级别
chkconfig --list redis #查看启动级别
service redis restart #重新启动redis
# 尝试启动或停止redis
service redis start
service redis stop