专注于magento建站与magento二次开发
提供magento教程 magento模板 magento插件

Magento 2 安装redis 加速网站

先安装redis

sudo apt-get install redis-server
查看redis状态
ps -aux|grep redis
redis     7207  0.0  0.1  40112  1712 ?        Ssl  09:56   0:00 /usr/bin/redis-server 127.0.0.1:6379
root      7221  0.0  0.0  14376   988 pts/0    S+   09:57   0:00 grep –color=auto redis
根据启动命令检查服务状态
netstat -nlt|grep 6379
sudo /etc/init.d/redis-server status
修改配置
sudo vi /etc/redis/redis.conf
redis-cli monitor
配置Magento 2 启用redis
编辑 app/etc/env.php文件
启用session
'session' =>
array (
  'save' => 'redis',
  'redis' =>
  array (
    'host' => '127.0.0.1',
    'port' => '6379',
    'password' => '',
    'timeout' => '2.5',
    'persistent_identifier' => '',
    'database' => '2',
    'compression_threshold' => '2048',
    'compression_library' => 'gzip',
    'log_level' => '1',
    'max_concurrency' => '6',
    'break_after_frontend' => '5',
    'break_after_adminhtml' => '30',
    'first_lifetime' => '600',
    'bot_first_lifetime' => '60',
    'bot_lifetime' => '7200',
    'disable_locking' => '0',
    'min_lifetime' => '60',
    'max_lifetime' => '2592000'
  )
),

启用全页面缓存

'cache' =>
array(
   'frontend' =>
   array(
      'default' =>
      array(
         'backend' => 'Cm_Cache_Backend_Redis',
         'backend_options' =>
         array(
            'server' => '127.0.0.1',
            'database' => '0',
            'port' => '6379'
            ),
    ),
    'page_cache' =>
    array(
      'backend' => 'Cm_Cache_Backend_Redis',
      'backend_options' =>
       array(
         'server' => '127.0.0.1',
         'port' => '6379',
         'database' => '1',
         'compress_data' => '0'
       )
    )
  )
),

清除缓存

redis-cli flushall

bin/magento cache:flush

bin/magento cache:clean

参考

http://devdocs.magento.com/guides/v2.0/config-guide/redis/redis-session.html

http://devdocs.magento.com/guides/v2.0/config-guide/redis/redis-pg-cache.html

 

 

赞(0) 打赏
未经允许不得转载:magento建站专家 - magento4you » Magento 2 安装redis 加速网站
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

magento建站magento二次开发联系QQ283475615

联系我们立即咨询

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏