php 无法连接到内存缓存

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10776184/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 23:01:46  来源:igfitidea点击:

Can't connect to memcache

phpapachecachingmemcached

提问by Toni Michel Caubet

I am trying to connect to memcache as they suggest:

我正在尝试按照他们的建议连接到 memcache:

$memcache = new Memcache();
$memcache->pconnect('localhost',11211);

But i get:

但我得到:

Notice: Memcache::pconnect() [memcache.pconnect]: Server localhost (tcp 11211) failed with: Connection refused (111) in /home/user/public_html/website.com/includes/basedatos.php on line 26

Any idea why?

知道为什么吗?

回答by Amber

You need to actually install the memcachedserver so that it can be connected to. On CentOS, this can be done with...

您需要实际安装memcached服务器,以便它可以连接。在 CentOS 上,这可以通过...

sudo yum install memcached

(on debian flavors of linux, use apt-getinstead of yum)

(在 linux 的 debian 风格上,使用apt-get代替yum

回答by Andrew Rout

This may be obvious, but make sure that memcached is actually running:

这可能很明显,但请确保 memcached 确实在运行:

service memcached start

回答by Ali.MD

memcache is diffrent with memcached

memcache 与 memcached 不同

and i thing you have installed memcache because $memcache = new Memcache();worked

我认为你已经安装了内存缓存,因为它$memcache = new Memcache();有效

you must started it on your server

你必须在你的服务器上启动它

check this 10 baby steps to install Memcached Server and access it with PHP

检查安装 Memcached Server 并使用 PHP 访问它的 10 个婴儿步骤