官网:http://redis.io/
下载包:
https://codeload.github.com/phpredis/phpredis/zip/develop
http://download.redis.io/releases/redis-3.2.5.tar.gz
tar -zxvf redis-4.0.2.tgz cd /opt/redis-4.0.2
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --enable-redis make && make install //Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/ ls /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/ redis.so
vim /usr/local/php/lib/php.ini extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/" #736行,指定redis模块目录 extension = "redis.so" #738行,修改参数项名称为extension,指定redis模块名称 systemctl restart php-fpm.service php -m | grep redis
cd /usr/local/nginx/html/ vim set.php <?php $redis = new redis(); $redis->connect('127.0.0.1', 6379); $redis->set('test',"hello"); echo $redis->get('test'); ?> curl http://127.0.0.1/set.php vim get.php <?php $redis = new redis(); $redis->connect('127.0.0.1', 6379); $result = $redis->get('test'); var_dump($result); ?> curl http://127.0.0.1/get.php //结果:string(10) "hello"