I m running centos 6. Using apache for handling php and nginx to handle scripts images and css
i have installed memcached server.
PORT="11211"
USER="memcached"
MAXCONN="4096"
CACHESIZE="512"
OPTIONS="-l 127.0.0.1"
i have also installed the module for php.
i created a new php file
$memcache = new Memcache;
$memcache->connect('127.0.0.1', 11211) or die ("Could not connect");
i checked the memcached status and it is running.
I am always getting "Could not connect".
I tried to change the value to 'localhost' from '127.0.0.1' - still not working.
$memcache = new Memcache();
$memcache->addServer('127.0.0.1', 11211) or die ("Could not connect");
var_dump($memcache->getExtendedStats());
$memcache->set('key', 'hello world', false, 60);
echo $memcache->get('key');
//$memcache->connect('127.0.0.1', 11211) or die ("Could not connect");
Output
array(1) { ["127.0.0.1:11211"]=> bool(false) }
What does connect and addServer do differently? Which is best way to do?
But i am not getting the Hello World
More updates on the code and on this problem..
phpinfo is showing memcached.
var_dump($memcache->get('key')); gives
bool(false)
why should i use addServer instead of connect?
More update on the code
$memcache = new Memcache;
$memcache->addServer('localhost', 11211);
echo $memcache->getServerStatus('localhost', 11211);
output : 1
//$memcache->set('key', 'hello world') or die("failed to store data");
output : failed to store data
few more details
getsebool httpd_can_network_memcache
it returns off
Should it return on?
Notice: Memcache::connect(): Server 127.0.0.1 (tcp 11211, udp 0) failed with: Permission denied (13)See Question&Answers more detail:os