安装redis扩展
1、安装redis模块
wget https://codeload.github.com/phpredis/phpredis/zip/php7 unzip php7 cd phpredis-php7/ /application/php/bin/phpize ./configure --with-php-config=/application/php/bin/php-config make make install Installing shared extensions: /application/php-7.1.7/lib/php/extensions/no-debug-non-zts-20160303/
2、检查模块是否存在
cd /application/php-7.1.7/lib/php/extensions/no-debug-non-zts-20160303/ ls redis.so redis.so
3、修改 php.ini
vim /application/php/lib/php.ini ... extension=redis.so #添加此行 ...
4、重启php-fpm
5、测试连接redis服务器
<?php #/application/nginx/html/d.php $redis = new Redis(); $redis->connect('192.168.88.2', 6379); $redis->auth('pass123.com'); $redis->set('key', 'mm'); //设置值 $res = $redis->get('key'); echo $res;
每天进步一点,加油!