【问题标题】:magento how to change session handler to memcached?magento 如何将会话处理程序更改为 memcached?
【发布时间】:2015-05-03 20:14:50
【问题描述】:

我是 Magento 的新手,我的服务器的默认 php 会话处理程序是 memcached。我刚刚安装了 Magento(第 2 版),但一直出现错误:

open(localhost:11211/sess_qmnpedun2j0ie0jed9g8r08pd0, O_RDWR) failed: No such file or directory

它正在尝试将文件处理程序用于 Memcached 会话。我应该如何在 Magento 中更改它? Google-ing 一直告诉我去 local.xml 并添加以下内容:

<session_save><![CDATA[memcached]]></session_save>
<session_save_path><![CDATA[tcp://localhost:11211?persistent=1&weight=2&timeout=10&retry_interval=10]]></session_save_path>

但问题是,我没有MAGENTO_DIR/app/etc/local.xml,所以我真的不知道该怎么办。

我通过他们的github 页面(命令行安装)中给出的链接安装了 Magento2。安装成功,数据库和所有内容都已创建。

如何更改会话处理程序以在 Magento-2 中使用 memcached?

【问题讨论】:

    标签: php magento session memcached magento2


    【解决方案1】:

    这是因为在 Magento2 中 local.xml 不再存在并被 config.php 替换,而 config.php.gitignore 中(因此您在 GitHub 中看不到它!)。

    Here 您可以找到创建 config.php 文件的说明。在页面底部的Segment details下,您可以看到如何定义您的个人配置。

    here 你可以在 Magento2 中找到config.php 文件的示例。

    例如,关于您的案例,您需要将此结构添加到您的 config.php 文件中:

        __/session
          |__/save
            |-- <files|db>
    

    所以我想你最终需要在 config.php 中添加类似的内容:

          'session' => 
              array (
                'save' => 'memcache',
                'save_path' => 'tcp://localhost:11211?persistent=1&weight=2&timeout=10&retry_interval=10'
               ),
    

    不要忘记调整路径(服务器和端口)以匹配您的环境。

    【讨论】:

    • 谢谢;现在我做了db,我将在生产环境中做memcache。
    【解决方案2】:

    在 magento 2.3.0 中删除了对 memcache 的支持。

    我创建了plugin,它允许使用内存缓存进行会话。

    文档可在此处获得:https://connect20.aveo-trade.cz/docs/user-guide-memcached-2.3.0.pdf

    【讨论】:

      猜你喜欢
      • 2011-09-09
      • 2014-03-25
      • 2018-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-09
      相关资源
      最近更新 更多