首页 > 解决方案 > memcached:解析 session.save_path 失败

问题描述

我正在尝试设置memcached为使用 PHP

我已经安装并确认可以使用php -i | grep memcached

我正在运行一个简单的 php 文件来测试 memcached:

<?php
session_start();
$_SESSION['some'] = 'thing';
echo session_id()."\n";
print_r($_SESSION);

当我运行它时,我得到一个错误:

Warning: session_start(): failed to parse session.save_path in /Applications/XAMPP/xamppfiles/htdocs/public_html/session/s.php on line 2
PHP Warning:  session_start(): Failed to initialize storage module: memcached (path: tcp://localhost:11211) in /Applications/XAMPP/xamppfiles/htdocs/public_html/session/s.php on line 2
Warning: session_start(): Failed to initialize storage module: memcached (path: tcp://localhost:11211) in /Applications/XAMPP/xamppfiles/htdocs/public_html/session/s.php on line 2

我找到了将 save_path 设置为此的建议:

session.save_path="tcp://localhost:11211?persistent=1&amp;weight=1&amp;timeout=1&amp;retry_interval=15"

但错误仍然存​​在。

这是我的 php.ini 的一部分

session.save_handler=memcached
session.save_path="tcp://localhost:11211?persistent=1&amp;weight=1&amp;timeout=1&amp;retry_interval=15"

内存缓存部分

Version 3.0.4
libmemcached version    1.0.18
SASL support    yes
Session support yes
igbinary support    no
json support    no
msgpack support no
memcached.compression_factor    1.3 1.3
memcached.compression_threshold 2000    2000
memcached.compression_type  fastlz  fastlz
memcached.default_binary_protocol   0   0
memcached.default_connect_timeout   0   0
memcached.default_consistent_hash   0   0
memcached.serializer    php php
memcached.sess_binary_protocol  1   1
memcached.sess_connect_timeout  0   0
memcached.sess_consistent_hash  1   1
memcached.sess_lock_expire  0   0
memcached.sess_lock_max_wait    not set not set
memcached.sess_lock_retries 5   5
memcached.sess_lock_wait    not set not set
memcached.sess_lock_wait_max    2000    2000
memcached.sess_lock_wait_min    1000    1000
memcached.sess_locking  1   1
memcached.sess_number_of_replicas   0   0
memcached.sess_persistent   0   0
memcached.sess_prefix   memc.sess.  memc.sess.
memcached.sess_randomize_replica_read   0   0
memcached.sess_remove_failed_servers    0   0
memcached.sess_sasl_password    no value    no value
memcached.sess_sasl_username    no value    no value
memcached.sess_server_failure_limit 0   0
memcached.store_retry_count 2   2

端口 11211 已打开:

$netstat -ap tcp | grep -i "listen"
tcp4       0      0  *.11211                *.*                    LISTEN     
tcp6       0      0  *.11211                *.*                    LISTEN 

我应该怎么做才能解决这个问题?

标签: phpmemcached

解决方案


推荐阅读