在侦听TCP端口时,我能够成功获得带有PHP 5.6的memcached版本
<?php
$m = new Memcached();
$m->addServer('localhost', 11211);
print_r($m->getStats());
print_r($m->getVersion());
?>
然后我得到了我期望的输出
root@debian8x64:~# php memcached
Array
(
[localhost:11211] => Array
(
[pid] => 22165
[uptime] => 8
[threads] => 4
[time] => 1460472519
[pointer_size] => 64
[rusage_user_seconds] => 0
[rusage_user_microseconds] => 0
[rusage_system_seconds] => 0
[rusage_system_microseconds] => 0
[curr_items] => 0
[total_items] => 0
[limit_maxbytes] => 67108864
[curr_connections] => 5
[total_connections] => 6
[connection_structures] => 6
[bytes] => 0
[cmd_get] => 0
[cmd_set] => 0
[get_hits] => 0
[get_misses] => 0
[evictions] => 0
[bytes_read] => 8
[bytes_written] => 0
[version] => 1.4.25
)
)
Array
(
[localhost:11211] => 1.4.25
)
当我更改为unix套接字并指定端口0
时$m->addServer('/var/run/memcached.sock', 0);
我得到了这个输出
Array
(
[/var/run/memached.sock:11211] => Array
(
[pid] => -1
[uptime] => 0
[threads] => 0
[time] => 0
[pointer_size] => 0
[rusage_user_seconds] => 0
[rusage_user_microseconds] => 0
[rusage_system_seconds] => 0
[rusage_system_microseconds] => 0
[curr_items] => 0
[total_items] => 0
[limit_maxbytes] => 0
[curr_connections] => 0
[total_connections] => 0
[connection_structures] => 0
[bytes] => 0
[cmd_get] => 0
[cmd_set] => 0
[get_hits] => 0
[get_misses] => 0
[evictions] => 0
[bytes_read] => 0
[bytes_written] => 0
[version] =>
)
)
Array
(
[/var/run/memached.sock:11211] => 255.255.255
)
我正在使用这些参数运行memcached,仅用于测试
memcached -u root -s /var/run/memcached.sock -a 755 -vvvv
我的memcached的php信息
memcached support => enabled
Version => 2.2.0
libmemcached version => 1.0.18
SASL support => yes
Session support => yes
igbinary support => no
json support => no
msgpack support => no
memcached
memcached support => enabled
libmemcached version => 1.0.18
memcached.compression_factor => 1.3 => 1.3
memcached.compression_threshold => 2000 => 2000
memcached.compression_type => fastlz => fastlz
memcached.serializer => php => php
memcached.sess_binary => 0 => 0
memcached.sess_connect_timeout => 1000 => 1000
memcached.sess_consistent_hash => 0 => 0
memcached.sess_lock_expire => 0 => 0
memcached.sess_lock_max_wait => 0 => 0
memcached.sess_lock_wait => 150000 => 150000
memcached.sess_locking => 1 => 1
memcached.sess_number_of_replicas => 0 => 0
memcached.sess_prefix => memc.sess.key. => memc.sess.key.
memcached.sess_randomize_replica_read => 0 => 0
memcached.sess_remove_failed => 0 => 0
memcached.store_retry_count => 2 => 2
答案 0 :(得分:0)
问题最终与权限相关,尽管我读过755还不够。如果你想保证memcached unix套接字在/ tmp文件夹中使用777工作,unix套接字将使它工作。
使用nginx或Apache的php5-fpm或php7.0-fpm可以found here使用更安全的解决方案。