當前最新的穩定版本是3.2.8,以此版本爲例php
wget http://download.redis.io/releases/redis-3.2.8.tar.gz tar xvf redis-3.2.8.tar.gz
cd redis-3.2.8 make sudo make install
sudo mkdir /etc/redis sudo cp redis.conf /etc/redis/6379.conf sudo vim /etc/redis/6379.conf
修改配置redis
daemonize yes
sudo cp ./utils/redis_init_script /etc/init.d/redis sudo vim /etc/init.d/redis
頭部註釋增長一行vim
# chkconfig: 2345 10 90
sudo chkconfig redis on
啓動並測試php-fpm
sudo service redis start redis-cli >quit
wget http://pecl.php.net/get/redis-3.1.2.tgz phpize ./configure --with-php-config=/usr/local/php/bin/php-config make sudo make install
若是沒有安裝autconf,請用yum install測試
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/ 修改php.innui
sudo vim /etc/php.ini
[redis] extension_dir = /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303 extension = redis.so
重啓 php-fpm.net
sudo service php-fpm restart
前面的test.php頁面應該可以看到redis擴展被啓用。 簡單測試代碼debug
<?php $redis = new Redis(); $redis->connect("127.0.0.1", 6379); $redis->set("say", "hello"); echo $redis->get("say"); $redis->del("say"); echo $redis->get("say");