Redis RedisPhp扩展安装

cd /usr/local/src

wget http://download.redis.io/releases/redis-3.0.0.tar.gz

tar zxvf redis-3.0.0.tar.gz

cd redis-3.0.0

make PREFIX=/usr/local/redis install

cd src && make test (如果报错)

说明需要安装 tcl 执行 sudo yum install tcl

Meke test

Cd ..

Src/redis-server ./redis.conf

在开一个终端查看

netstat –tlnp

tcp        0      0 0.0.0.0:6379                0.0.0.0:*                   LISTEN      6432/redis-server

cp ./redis.conf /usr/local/redis/ vim /usr/local/redis/redis.conf

daemonize yes #redis将以守护进程的方式运行,默认为no会暂用你的终端 timeout 300 #当客户端闲置多长时间后关闭连接,如果指定为0,表示关闭该功能

设置自动启动 vim /etc/init.d/redis

#!/bin/sh
#
# redis        Startup script for Redis Server
#
# chkconfig: - 80 12
# description: Redis is an open source, advanced key-value store.
#
# processname: redis-server
# config: /etc/redis.conf
# pidfile: /var/run/redis.pid
source /etc/init.d/functions
BIN="/usr/local/redis/bin"
CONFIG="/usr/local/redis/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

chmod 755 /etc/init.d/redis

service redis start

service redis stop

 cd /usr/local/redis/bin

./redis-cli

 

redis php 扩展安装

wget https://github.com/nicolasff/phpredis/zipball/master -O php-redis.zip unzip php-redis.zip cd nicolasff-phpredis-2d0f29b/ /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config make && make install

完成后redis.so被安装到 /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/

vi /usr/local/php/lib/php.ini

添加 extension=redis.so

重启php-fpm即可。

configure时可能会遇到,添加--with-php-config参数可以解决。

configure: error: Cannot find php-config. Please use --with-php-config=PATH

./configure --with-php-config=/usr/local/php/bin/php-config