1.下載最新版本:php
$ wget http://download.redis.io/releases/redis-4.0.8.tar.gz $ tar xzf redis-4.0.8.tar.gz $ cp -p redis-4.0.8 /usr/local/redis4 $ cd redis4 $ make
這樣就安裝成功redis
2. 運行redis, 進入src目錄,運行下面命令apache
$ src/redis-server
3. 測試:vim
$ src/redis-cli redis> set hello world OK redis> get hello "world"
4. 自啓動php7
$ cp /usr/local/redis4/redis.conf /etc/redis.conf $ vim /etc/redis.conf 編輯以下 daemonize yes $ cp /usr/local/redis4/utils/redis_init_script /etc/rc.d/init.d/redis $ cd /etc/rc.d/init.d/ $ vim redis #把裏面的運行目錄換成你本身的,並加上chkconfig和description #!/bin/sh # # Simple Redis init.d script conceived to work on Linux systems # as it does use of the /proc filesystem. # chkconfig: 2345 90 10 # description: Redis is a persistent key-value database REDISPORT=6379 EXEC=/usr/local/redis4/src/redis-server CLIEXEC=/usr/local/redis4/src/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
$ chkconfig redis on $ service redis start #啓動 $ service redis stop #關閉服務
1.下載安裝擴展測試
$ wget http://pecl.php.net/get/redis-4.0.0RC2.tgz $ tar zxvf redis-4.0.0RC2.tgz $ cd redis-4.0.0RC2 $ /usr/local/php7/bin/phpize ----給PHP動態添加擴展命令,在php的bin目錄下 $ ./configure -with-php-config=/usr/local/php7/bin/php-config $ make && make install
2.在php.ini裏添加擴展名稱spa
$ vim /usr/local/php7/etc/php.ini extension=redis.so --添加擴展名稱