1. Download the source code, decompress it, and compile the source code.
$ wget http://download.redis.io/releases/redis-2.8.3.tar.gz$ tar xzf redis-2.8.3.tar.gz$ cd redis-2.8.3$ make
2. After compilation, there are four executable files in the src directory: redis-server, redis-benchmark, redis-CLI, and redis. conf. Then copy to a directory
mkdir /usr/rediscp redis-server /usr/rediscp redis-benchmark /usr/rediscp redis-cli /usr/rediscp redis.conf /usr/rediscd /usr/redis
3. Configuration
VI/etc/redis. modify the conf file as follows: daemonize yes # whether to run logfile/dev/null as a daemon # disable log DIR/var/lib/redis/useradd redismkdir-P/var/lib/redischown redis. redis/var/lib/redis # Put the DB file here
4. Edit the Startup Script
vim /etc/init.d/redis
#!/bin/bash # # Init file for redis # # chkconfig: - 80 12 # description: redis daemon # # processname: redis # config: /etc/redis.conf # pidfile: /var/run/redis.pid source /etc/init.d/functions #BIN="/usr/local/bin" BIN="/usr/local/bin" CONFIG="/etc/redis.conf" PIDFILE="/var/run/redis.pid" ### Read configuration [ -r "$SYSCONFIG" ] && source "$SYSCONFIG" RETVAL=0 prog="redis-server" desc="Redis Server" start() { if [ -e $PIDFILE ];then echo "$desc already running...." exit 1 fi echo -n $"Starting $desc: " daemon $BIN/$prog $CONFIG RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog return $RETVAL } stop() { echo -n $"Stop $desc: " killproc $prog RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog $PIDFILE return $RETVAL } restart() { stop start } case "$1" in start) start ;; stop) stop ;; restart) restart ;; condrestart) [ -e /var/lock/subsys/$prog ] && restart RETVAL=$? ;; status) status $prog RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|restart|condrestart|status}" RETVAL=1 esac exit $RETVAL######
5. Start
/etc/init.d/redis start
6. Set startup and add it to system services.
Chmod 775/etc/init. d/redis # Start redischkconfig redis on
Redis installation configuration and startup