PHP会话未保存在内存缓存中 [英] PHP sessions not being saved in memcache

查看:130
本文介绍了PHP会话未保存在内存缓存中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Amazon Linux在AWS上运行应用程序。

Running an application using php 5.4 on AWS using the Amazon Linux.

PHP版本是PHP 5.4.28。
从AWS repo安装的memcache lib是php54-pecl-memcache-3.0.8-1.11.amzn1.x86_64

PHP version is PHP 5.4.28. memcache lib installed from the AWS repo is php54-pecl-memcache-3.0.8-1.11.amzn1.x86_64

我已经验证php正在使用/ etc / php.ini:

I have verified that php is using /etc/php.ini:

[root@ip-xx.xx.xx.xx]# php -i | grep Config
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini

设置显示我应该使用memcache:

The setting show that I should be using memcache:

[root@ip-10-40-17-119 etc]# grep "^session.save" php.ini
session.save_handler="memcache"
session.save_path="tcp://<elasticache-endpoint>:11211"

[root@ip-10-40-17-119 php.d]# php -i | grep session.save
session.save_handler => memcache => memcache
session.save_path => tcp://<elasicache-endpoint>:11211?persistent=1&weight=1&timeout=1&retry_interval=15 => tcp://<elasticache-endpoint>:11211?persistent=1&weight=1&timeout=1&retry_interval=15

我可以telnet从框到结束点&端口并正确连接,因此实例能够连接到memcached服务器。

I can telnet from the box to the end point & port and connect properly, so the instance is able to connect to the memcached server.

我们尝试的东西:


  • 我删除了tcp:

  • 我们已经从session.save_handler =memcache更改为session.save_handler = memcached

  • 每次我们进行更改时,我们停止httpd服务器,然后再次启动

  • 我们甚至尝试重新启动服务器

  • I have removed the tcp:// from the php.ini file, and that made no difference - sessions are still getting saved in files.
  • We have changed from session.save_handler="memcache" to session.save_handler="memcached"
  • each time we make a change, we stop the httpd server, and then start it again
  • we have even tried rebooting the servers

无论我们尝试了什么,会话都存储在/ var / lib / php / sessions。
有没有什么我缺少,或者是已知的5.4或AWS问题?

Regardless of what we've tried, sessions are stored on disk to /var/lib/php/sessions. Is there something I'm missing, or is this a known 5.4 or AWS issue?

推荐答案

设法找出问题。

首先,我们创建了一个简单的页面,发出phpinfo()。注意,你通过web服务器运行这是很重要的 - 运行php -i不包括apache可能添加的任何覆盖。

First, we created a simple page that spit out phpinfo(). Note that it is important that you run this thru the web server - running php -i DOES NOT include any overrides that apache may add.

在会话部分下,输出列出所有指令,以及本地值和主值。

Under the session section, the output lists all the directives, and a "Local Value" and a "Master Value".

本地值具有:

session.save_handler    files
session.save_path   /var/lib/php/session

而主值具有:

session.save_handler    memcache
session.save_path   tcp://<endpoint>:11211

事实证明,在/etc/httpd/conf.d/php.conf中指定文件。这似乎是一个Redhat / CentOS / Fedora的事情。

It turns out that there's an override installed by default in /etc/httpd/conf.d/php.conf that specifies the files. This appears to be a Redhat/CentOS/Fedora thing.

从php.conf中删除这些值修复了问题。

Removing those values from php.conf fixed the problem.

这篇关于PHP会话未保存在内存缓存中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆