Php cannot connect to memcache yesterday. a memcache is installed on the linux Virtual Machine and data can be normally accessed in php. I restarted linux today and found that php could not connect to memcache, but telnet could be used to connect and access data. I hope you can help me to solve the problem, close the post immediately, and score the comments and top points.
My php code is as follows:
$ Memcache = new Memcache;
$ Memcache-> connect ('localhost', 11211 );
$ Memcache-> set ('key', 'test ');
$ Get_value = $ memcache-> get ('key ');
Echo $ get_value;
Reply to discussion (solution)
Is the port not occupied?
Generation? Normal.
If telnet succeeds, the port is normal.
Telnet local host 11211
Set key 0 0 3
123
Check whether it can be saved ?.
Unable to connect. There will always be error messages. Paste it out.
Paste a connection to you:
Http://stackoverflow.com/questions/18420113/memcache-for-php-unable-to-connect
Find the error message.
No error message. how can this problem be solved?
Thanks to microlab2009, fdipzone, ohmygirl, nowphp, u010541899,
Through settings, php displays an error message, which is a selinux problem. when it is enabled, php is prohibited from connecting to memcache. after it is disabled, everything works normally.