/usr/local/php-fpm/bin/pecl install redis
vi /usr/local/php/etc/php.ini //增加extension = redis.so
通过源码安装
wget https://github.com/phpredis/phpredis/archive/4.2.0.tar.gz
mv 4.2.0.tar.gz php-redis.tar.gz
tar zxvf php-redis.tar.gz
cd phpredis-4.2.0/
/usr/local/php-fpm/bin/phpize
./configure --with-php-config=/usr/local/php-fpm/bin/php-config
make && make install
vi /usr/local/php/etc/php.ini //增加extension = redis.so
php中使用redis - 存储session
vim /usr/local/php-fpm/etc/php.ini//更改或增加
session.save_handler = "redis"
session.save_path = "tcp://127.0.0.1:6379"
或者apache虚拟主机配置文件中也可以这样配置:
php_value session.save_handler "redis"
php_value session.save_path "tcp://127.0.0.1:6379"
或者php-fpm配置文件对应的pool中增加:
php_value[session.save_handler] = re