On my CentOS 7, Memcached is running and working on SSH but not working in the PHP file. I've followed this article: https://www.mynotepaper.com/install-memcached-on-centos-7. This method was working fine on my previous server.
I've tested Memcached using telnet. It works fine.
$ telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
set test 0 100 5
Hello
STORED
get test
VALUE test 0 5
Hello
END
After storing data using telnet, I've tested on SSH via PHP command. It works too:
php -r '$c = new Memcached(); $c->addServer("127.0.0.1", 11211); var_dump( $c->getAllKeys() );'
array(1) {
[0]=>
string(4) "test"
}
But in PHP file, it doesn't work. The PHP code:
<?php
$c = new Memcached();
$c->addServer("127.0.0.1", 11211);
var_dump( $c->getAllKeys() );
?>
It always shows bool(false)
. Here's my PHP info's screenshot.
Could you please tell me what's my mistake?
To allow a httpd integrated PHP module to do network access (even if it is to loopback network) in an enforcing SELinux environment, you have to do on your server (as root or with sudo):
Listing of booleans and info on Centos Wiki: https://wiki.centos.org/TipsAndTricks/SelinuxBooleans