我遇到在远程memcache服务器上存储会话数据的问题。这是我得到的错误:
[Wed Dec 14 07:33:18 2016] [error] [client 192.168.247.235] PHP Warning: Unknown: Failed to write session data (memcache). Please verify that the current setting of session.save_path is correct (tcp://192.168.247.111:11211) in Unknown on line 0
在同一台服务器上,如果我尝试使用telnet,它可以工作:
[root@centos ~]# telnet 192.168.247.111 11211
Trying 192.168.247.111...
Connected to 192.168.247.111.
Escape character is '^]'.
set test 0 100 3
xxx
STORED
get test
VALUE test 0 3
xxx
END
的php.ini:
session.save_handler=memcache
session.save_path="tcp://192.168.247.111:11211"
当我在php.ini中使用memcached时会发生同样的事情:
session.save_handler=memcached
session.save_path="192.168.247.111:11211"
在error_log中提供更多信息
[Wed Dec 14 07:46:02 2016] [error] [client 192.168.247.235] PHP Warning: session_start(): Write of lock failed in /var/www/html/sess.php on line 2
[Wed Dec 14 07:46:02 2016] [error] [client 192.168.247.235] PHP Warning: session_start(): Unable to clear session lock record in /var/www/html/sess.php on line 2
[Wed Dec 14 07:46:02 2016] [error] [client 192.168.247.235] PHP Warning: Unknown: Failed to write session data (memcached). Please verify that the current setting of session.save_path is correct (192.168.247.111:11211) in Unknown on line 0
php文件只有3行:
<?
session_start();
$_SESSION['somekey'] = "someval";
print_r($_SESSION);
答案 0 :(得分:0)
经过几天的测试和谷歌搜索后,我发现SElinux就是问题所在。禁用后,一切都开始工作了。