简体   繁体   English

Heroku上的memcached php会话

[英]memcached php sessions on heroku

I had noticed that an application I have setup on heroku only shows sessions variables on random requests when I refresh the browser. 我已经注意到,当我刷新浏览器时,在heroku上安装的应用程序仅在随机请求上显示会话变量。 I put this down to the fact the application is running on 5 dynos. 我将其归因于该应用程序在5 dynos上运行。

I followed the following tutorial to solve this with memcached using memcachedcloud. 我按照以下教程使用memcachedcloud使用memcached解决了此问题。

https://devcenter.heroku.com/articles/php-sessions#storing-sessions-in-memcached https://devcenter.heroku.com/articles/php-sessions#storing-sessions-in-memcached

The issue still remains though. 问题仍然存在。 I am using the PHP slim framework, is there any further config I need for this? 我正在使用PHP苗条框架,对此是否需要其他配置? I cant seem to find anything in the slim docs. 我似乎在苗条的文档中找不到任何内容。

EDIT: 编辑:

I can not produce the required composer.lock file because when running. 由于无法运行,因此无法生成所需的composer.lock文件。

composer update

I get the error 我得到错误

The requested PHP extension ext-memcached * is missing from your system.

But it is in fact installed. 但实际上已安装。 I can see the version from typing. 我可以通过键入看到版本。

memcached -h

But it is not present when typing 但键入时不存在

composer show --platform

Depending on what platform you're running, you have to make sure you that composer updates. 根据您正在运行的平台,您必须确保您的作曲家已更新。 Even if you have memcached installed, it has to match your PHP version. 即使您已安装memcached,它也必须与您的PHP版本匹配。 Then, once installed, run composer update 然后,安装后,运行composer update

For example: 例如:

If you have PHP5.6.15, get memcached with, either, brew install php56/memcached or sudo apt-get install php56/memcached . 如果您拥有PHP5.6.15,请通过brew install php56/memcachedsudo apt-get install php56/memcached

Then run composer update . 然后运行composer update

If you have an issue installing composer on Mac, you have to enable rootless install. 如果在Mac上安装composer时遇到问题,则必须启用rootless安装。 More info can be found here: 可以在这里找到更多信息:

https://donatstudios.com/OS-X-Mavericks-Memcached-PHP-Extension-Installation https://donatstudios.com/OS-X-Mavericks-Memcached-PHP-Extension-Installation

The gist of the steps to take are: 要采取的步骤的要点是:

  • Restart computer and hold Command + R to get into recover mode 重新启动计算机并按住Command + R进入恢复模式
  • Get into the terminal from Utilities 从实用程序进入终端
  • Run csrutil disable and restart 运行csrutil disable并重新启动

This should be done prior to installing memcached from Homebrew. 这应该在从Homebrew安装memcached之前完成。

Hope this helps. 希望这可以帮助。

I had a similar issue, where I was getting the same "ext-memcached * is missing" error and could not see ext-memcached when running composer show --platform . 我遇到了类似的问题,我遇到了同样的“ ext-memcached *丢失”错误,并且在运行composer show --platform时看不到ext-memcached

I noticed that when I originally installed memcached, homebrew showed me various alternatives. 我注意到,当我最初安装memcached时,自制软件向我展示了多种选择。 So on Mac OSX El Capitan, I ended up installing the one that matched my PHP version: 因此,在Mac OSX El Capitan上,我最终安装了与我的PHP版本匹配的版本:

brew install homebrew/php/php55-memcached

And then I had to add it to php.ini: 然后我必须将其添加到php.ini中:

extension=/usr/local/Cellar/php55-memcached/2.2.0/memcached.so

You can get the correct version path with: 您可以通过以下方式获取正确的版本路径:

brew info php55-memcached

And then I restarted Apache: 然后我重新启动了Apache:

sudo apachectl restart

It finally showed up in the composer list and I was able to update composer without error. 它终于出现在作曲家列表中,并且我能够无错误地更新作曲家。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM