1.首先下載redis到本地,解壓
2.進(jìn)入解壓后的文件夾內(nèi)安裝
[root@localhost /]# cd redis
[root@localhost /]# make
.................................................(各種安裝信息)
[root@localhost /]# make install
.................................................(各種安裝信息)
3.復(fù)制目錄下的配置文件到/etc
[root@localhost /]# cp redis.conf /etc/
4.修改配置文件將redis設(shè)置為后臺(tái)運(yùn)行, 將配置文件中daemonize為yes
[root@localhost /]# vim /etc/redis.conf
將配置文件中daemonize為yes
5.配置自動(dòng)啟動(dòng)
[root@localhost /]# vim /etc/init.d/redis
將下面內(nèi)容復(fù)制進(jìn)去
#!/bin/sh
# chkconfig:2345 80 90
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.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
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
*)
echo "Please use start or stop as first argument"
;;
esac
#設(shè)置權(quán)限
[root@localhost ~]# chmod 777 /etc/init.d/redis
#啟動(dòng)redis
[root@localhost ~]# service redis start