安装redis组件
登陆宝塔BT后台,找到左侧,软件管理-你站点对应的php版本,设置-安装扩展-找到redis安装,完成后记得重启下php。如果你用的不是宝塔BT面板,请自行百度安装php扩展redis,蛮多教程。
开启性能优化
$config['setting']['redis']['server'] = '127.0.0.1'; //默认本地,你也可以用云库地址(远程) $config['setting']['redis']['port'] = 6379; //默认端口 $config['setting']['redis']['pconnect'] = 1; $config['setting']['redis']['auth'] = ''; //redis密码, 默认为空 $config['setting']['redis']['requirepass'] = ''; //redis密码,默认为空,没用人人商城删除这行 $config['setting']['redis']['timeout'] = 1;
这样就微擎redis就配置好了,但并没有开启哦,开启详见如下代码,这段你默认就有,注意修改位置
$config['setting']['charset'] = 'utf-8'; $config['setting']['cache'] = 'redis'; // 默认是mysql,改为redis $config['setting']['timezone'] = 'Asia/Shanghai'; $config['setting']['memory_limit'] = '256M'; $config['setting']['filemode'] = 0644; $config['setting']['authkey'] = 'fa6f7528'; $config['setting']['founder'] = '1'; $config['setting']['development'] = 0; $config['setting']['referrer'] = 0; $config['setting']['https'] = 1;
注意第二行,mysql修改为redis就开启缓存了,你可以登陆后台,在站点-性能优化里看到redis已开启。
远程云库redis
$config['setting']['redis']['server'] = 'xxx.redis.aliyun.com'; //云库地址 $config['setting']['redis']['port'] = 6379; //云库端口 $config['setting']['redis']['pconnect'] = 1; $config['setting']['redis']['auth'] = 'xxxxxx'; //redis密码 $config['setting']['redis']['requirepass'] = 'xxxxxx'; //redis密码,没用人人商城删除这行 $config['setting']['redis']['timeout'] = 1;
注意事项
$config['setting']['cache'] = 'mysql'; // 停用缓存了
发表评论