Php cannot connect to memcache

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.