- 编译安装redis
//linux版本下载地址:https://redis.io/tar -zvxf redis-4.0.1.tar.gzcd redis-4.0.1make//执行命令移动cd srcmkdir /usr/redisbincp redis-server /usr/redisbincp redis-benchmark /usr/redisbincp redis-cli /usr/redisbincp ../redis.conf /etc//更改为守护进程vi /etc/redis.conf daemonize yes
- 开机启动脚本
vi /etc/init.d/redis
# chkconfig: 2345 10 90 # description: Start and Stop redis PATH=/usr/local/bin:/sbin:/usr/bin:/bin REDISPORT=6379 EXEC=/usr/redisbin/redis-server REDIS_CLI=/usr/redisbin/redis-cli PIDFILE=/var/run/redis.pid CONF="/etc/redis.conf" AUTH="1234" 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 if [ "$?"="0" ] then echo "Redis is running..." fi ;; stop) if [ ! -f $PIDFILE ] then echo "$PIDFILE exists, process is not running." else PID=$(cat $PIDFILE) echo "Stopping..." $REDIS_CLI -p $REDISPORT SHUTDOWN sleep 2 while [ -x $PIDFILE ] do echo "Waiting for Redis to shutdown..." sleep 1 done echo "Redis stopped" fi ;; restart|force-reload) ${0} stop ${0} start ;; *) echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2 exit 1 esac
//权限设置chmod 755 /etc/init.d/redis//启动测试service redis restar使用redis-cli测试:[root@rk ~]# /usr/redisbin/redis-cli127.0.0.1:6379> set foo barOK127.0.0.1:6379> get foo"bar"127.0.0.1:6379> exit//开机启动设置chkconfig redis on
- php扩展编译
cd redis-3.1.3/usr/bin/phpize./configure --with-php-config='/usr/bin/php-config'make && make installvi /etc/php.ini//添加extension=redis.so