2

I am able to successfully get the memcached version with PHP 5.6 when listening on a TCP port

<?php
$m = new Memcached();
$m->addServer('localhost', 11211);
print_r($m->getStats());
print_r($m->getVersion());
?>

Then I get the output I expect

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
)

When I change to a unix socket and specify port 0

$m->addServer('/var/run/memcached.sock', 0);

I get this output

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
)

I am running memcached with these parameters just for testing

memcached -u root -s /var/run/memcached.sock -a 755 -vvvv

My php info for memcached

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
Mike Andreasen
  • 379
  • 2
  • 11

1 Answers1

0

The issue ended up being permissions related, despite what I had read 755 is not sufficient. If you want to guarantee the memcached unix socket works using 777 in the /tmp folder for the unix socket will make it work.

The more secure solution can be found here to use with php5-fpm or php7.0-fpm with nginx or Apache.

Mike Andreasen
  • 379
  • 2
  • 11