PHP memcached 致命错误:找不到“Memcache”类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2659035/
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-25 07:14:31  来源:igfitidea点击:

PHP memcached Fatal error: Class 'Memcache' not found

phpmemcachedubuntu-9.10

提问by jpfuentes2

I've pasted the example from php.netfor using memcached in php and I'm getting:

我已经从php.net粘贴了在 php 中使用 memcached的示例,我得到:

Fatal error: Class 'Memcache' not found

I have this in my php.ini:

我的 php.ini 中有这个:

[memcache]
memcache.hash_strategy = "consistent"
memcache.max_failover_attemps = 100
memcache.allow_failover = 1

[memcache]
memcache.hash_strategy = "一致"
memcache.max_failover_attemps = 100
memcache.allow_failover = 1

Here's info from php -i and php -m respectively:

这是分别来自 php -i 和 php -m 的信息:

php -i | grep -i memcache
memcached
memcached support => enabled
libmemcached version => 0.37
Registered save handlers => files user sqlite memcached

php -m | grep -i memcache
memcached

php -i | grep -i memcache
memcached
memcached 支持 => 启用
libmemcached 版本 => 0.37
注册保存处理程序 => 文件用户 sqlite memcached

php -m | grep -i memcache
memcached

So php seems to have loaded memcached as a module, and php info says that it is loaded and is using v .37. I have not tried yet via apache, I've only been using this through cli right now. Any thoughts?

因此 php 似乎已将 memcached 作为模块加载,而 php info 表示它已加载并使用 v .37。我还没有通过 apache 尝试过,我现在只是通过 cli 使用它。有什么想法吗?

回答by Charles

There are two extensions for memcached in PHP, "memcache" and "memcached".

PHP 中有两个 memcached 扩展,“ memcache”和“ memcached”。

It looks like you're trying to use one ("memcache"), but the other is installed ("memcached").

看起来您正在尝试使用一个(“memcache”),但另一个已安装(“memcached”)。

回答by Phill Healey

Dispite what the accepted answer says in the comments, the correct way to install 'Memcache' is:

不管评论中接受的答案是什么,安装“Memcache”的正确方法是:

sudo apt-get install php5-memcache

NOTEMemcache & Memcached are two distinct although related pieces of software, that are often confused.

注意Memcache 和 Memcached 是两个不同但相关的软件,它们经常被混淆。

EDITAs this is now an old post I thought it worth mentioning that you should replace php5with your php version number.

编辑因为这是一个旧帖子,我认为值得一提的是你应该用你的 php 版本号替换php5

回答by Xman Classical

I found solution in this post: https://stackoverflow.com/questions/11883378/class-memcache-not-found-php#=

我在这篇文章中找到了解决方案:https: //stackoverflow.com/questions/11883378/class-memcache-not-found-php# =

I found the working dll files for PHP 5.4.4

我找到了 PHP 5.4.4 的工作 dll 文件

I don't knowhow stable they are but they work for sure. Credits goes to this link.

我不知道它们有多稳定,但它们确实有效。积分转到此链接。

http://x32.elijst.nl/php_memcache-5.4-nts-vc9-x86.zip

http://x32.elijst.nl/php_memcache-5.4-nts-vc9-x86.zip

http://x32.elijst.nl/php_memcache-5.4-vc9-x86.zip

http://x32.elijst.nl/php_memcache-5.4-vc9-x86.zip

It is the 2.2.5.0 version, I noticed after compiling it (for PHP 5.4.4).

它是 2.2.5.0 版本,我在编译后注意到(对于 PHP 5.4.4)。

Please note that it is not 2.2.6 but works. I also mirrored them in my own FTP. Mirror links:

请注意,它不是 2.2.6 而是有效。我也在我自己的 FTP 中镜像了它们。镜像链接:

http://mustafabugra.com/resim/php_memcache-5.4-vc9-x86.ziphttp://mustafabugra.com/resim/php_memcache-5.4-nts-vc9-x86.zip

http://mustafabugra.com/resim/php_memcache-5.4-vc9-x86.zip http://mustafabugra.com/resim/php_memcache-5.4-nts-vc9-x86.zip

回答by Dalius ?idlauskas

The right is php_memcache.dll. In my case i was using lib compiled with vc9 instead of vc6 compiler. In apatche error logs i got something like:

右边是php_memcache.dll。就我而言,我使用的是用 vc9 编译的 lib 而不是 vc6 编译器。在补丁错误日志中,我得到了类似的信息:

PHP Startup: sqlanywhere: Unable to initialize module Module compiled with build ID=API20090626, TS,VC9 PHP compiled with build ID=API20090626, TS,VC6 These options need to match

PHP Startup: sqlanywhere: Unable to initialize module Module installed with build ID=API20090626, TS,VC9 PHPcompiled with build ID=API20090626, TS,VC6 这些选项需要匹配

Check if you have same log and try downloading different dll that are compiled with different compiler.

检查您是否有相同的日志并尝试下载使用不同编译器编译的不同 dll。

回答by Maihan Nijat

For OSX users:

对于 OSX 用户:

Run the following command to install Memcached:

运行以下命令安装 Memcached:

brew install memcached

回答by ewakened

I went into wp-config/ and deleted the object-cache.php and advanced-cache.php and it worked fine for me.

我进入 wp-config/ 并删除了 object-cache.php 和 advanced-cache.php ,它对我来说很好用。