I have PHP 5.3.3 installed on Centos 6.4 with the memcached.so
extension, and httpd is running with version 2.2.15-26. Here is my index.php
:
$mc = new \Memcached();
$mc->addServer('127.0.0.1', 11211);
$mc->set("test", "blah");
var_dump($mc->getResultCode());
var_dump($mc->getResultMessage());
var_dump($mc->get("test"));
die;
When I run it from the command line, it works. I get the following:
10:22:33 $ php index.php
int(0)
string(7) "SUCCESS"
string(4) "blah"
The memcache server also works from telnet. However, when I run index.php
from the web, it fails. I get the following (from viewing webpage source):
int(47)
string(51) "SERVER HAS FAILED AND IS DISABLED UNTIL TIMED RETRY"
bool(false)
Short of re-installing my OS and trying different versions of crap, can anyone explain what might cause this issue?
I have similar issue on CentOS and what I found it I am running SELinux which prevent httpd to connect to memcached. You need to set below,
# setsebool -P httpd_can_network_memcache 1
# getsebool httpd_can_network_memcache
httpd_can_network_memcache --> on
Is it an SELinux problem ? Cli can access to Memcached but daemon no. Try this :
getenforce
to know if you have SELinux enabledsetenforce 0
to disable itreboot
If is good, You must configure Apache to access to Memcached.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With