#無wget,請通過命令yuminstallwget安裝
wgethttp:
//download
.redis.io
/releases/redis-3
.0.1.
tar
.gztarxzfredis-3.0.1.
tar
.gz
cd
redis-3.0.1make
#如果無make命令,請下載yuminstallgccmakemaketestmakeinstall
安裝好了redis後,須注意拷貝bin文件到usr/local/bin(這步很重要,無這步會報錯)
?cp
redis-server
/usr/local/bin/cp
redis-cli
/usr/local/bin
之後修改redis.conf,打開後台運行選項:
?daemonize
yes
編寫啟動shell:vim/etc/init.d/redis(copy網上的)
?#chkconfig:23451090#description:StartandStopredis
PATH=
/usr/local/bin
:
/sbin
:
/usr/bin
:
/bin
REDISPORT=6379
#實際環境而定EXEC=/usr/local/redis/src/redis-server#實際環境而定REDIS_CLI=/usr/local/redis/src/redis-cli#實際環境而定
PIDFILE=
/var/run/redis
.pid
CONF=
"/usr/local/redis/redis.conf"
#實際環境而定
case
"$1"
in
start)
if
[-f$PIDFILE]
then
echo
"$PIDFILEexists,processisalreadyrunningorcrashed."
else
echo
"StartingRedisserver..."
$EXEC$CONF
fi
if
[
"$?"
=
"0"
]
then
echo
"Redisisrunning..."
fi
;;
stop)
if
[!-f$PIDFILE]
then
echo
"$PIDFILEexists,processisnotrunning."
else
PID=$(
cat
$PIDFILE)
echo
"Stopping..."
$REDIS_CLI-p$REDISPORTSHUTDOWN
while
[-x$PIDFILE]
do
echo
"WaitingforRedistoshutdown..."
sleep
1
done
echo
"Redisstopped"
fi
;;
restart|force-reload)${0}stop${0}start
;;
*)
echo
"Usage:/etc/init.d/redis{start|stop|restart|force-reload}"
>&2
exit
1esac
賦予權限chmod+x /etc/init.d/redis
設置開機啟動:
?#嘗試啟動或停止redisserviceredisstartserviceredisstop
#開啟服務自啟動chkconfigredison
http://xxxxxx/Linuxjc/1134260.html TechArticle