简体   繁体   English

致命错误:未找到类'Memcache'(与pecl一起安装)

[英]Fatal error: Class 'Memcache' not found (installed with pecl)

I installed memcache via ssh, with: 我通过ssh安装了memcache,用:

$ pecl install memcache

And this was the output: https://pastee.org/w63sy 这是输出: https//pastee.org/w63sy

And added this line to etc/php.ini : 并将此行添加到etc/php.ini

extension=memcache.so

And when trying to initialize: 在尝试初始化时:

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

I get: 我明白了:

Fatal error: Class 'Memcache' not found in /home/piscolab/public_html/website.com/includes/sql.php on line 25

What am I doing wrong? 我究竟做错了什么?

I found this question but the problem was about his shared server. 我发现了这个问题,但问题出在于他的共享服务器。 I am under a VPS. 我在VPS下。

Running: php -i | grep php.ini 正在运行: php -i | grep php.ini php -i | grep php.ini : php -i | grep php.ini

[root@vps ~]# php -i | grep php.ini                                                                                                                                            
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/memcache.so' - /usr/lib/php/modules/memcache.so: cannot open shared object file: No such file o
r directory in Unknown on line 0                                                                                                                                               
Configuration File (php.ini) Path => /etc                                                                                                                                      
Loaded Configuration File => /etc/php.ini                                                                                                                                      
[root@vps ~]#    

Finding memcache.so (no output) 查找memcache.so(无输出)

[root@vps ~]# find / -type f -name memcache*.so'                                                                                                                              
[root@vps ~]# find / -type f -name memcache*.so                                                                                                                                
[root@vps ~]#

Given the output of the error message, it looks like you are missing the zlib development libraries, or at least they are not in the usual location where it can be automatically found by configure. 给定错误消息的输出,看起来您缺少zlib开发库,或者至少它们不在通常由configure自动找到的位置。

Since you are on CentOS, try installing the libraries with this command: 由于您使用的是CentOS,请尝试使用以下命令安装库:

yum install zlib-devel

This installs the zlib library which is required for memcache. 这将安装memcache所需的zlib库。 Try re-running the pecl installer after installing the zlib libraries. 安装zlib库后,请尝试重新运行pecl安装程序。

it will probably help if you give some more info via phpinfo() or php_config, more specifically, does your install see the memcache libs and are your lib paths correct. 如果您通过phpinfo()或php_config提供更多信息可能会有所帮助,更具体地说,您的安装是否会看到memcache库并且您的lib路径是否正确。

php-config

will tell you more, interesting here are the php ini path used and the lib paths php ini path will be displayed when you use --configure-options, suboption --with-config-file-path (/etc/php5/apache2 in my specific case) and the lib paths will be displayed with --extension-dir 将告诉你更多,有趣的是这里使用的php ini路径和lib路径php ini路径将显示当你使用--configure-options,suboption --with-config-file-path(/ etc / php5 / apache2 in我的特定情况)和lib路径将显示--extension-dir

eg 例如

php-config --extension-dir

php-config --configure-options | grep -o 'with-config-file-path[^ ,.]*' | grep -o '[^=.]*$'

So to use my example my lib paths are set to 因此,要使用我的示例,我的lib路径设置为

/usr/lib/php5/20090626+lfs and an / usr / lib / php5 / 20090626 + lfs和an

ls /usr/lib/php5/20090626+lfs/mem*  

command for my system reveals: 我系统的命令显示:

/usr/lib/php5/20090626+lfs/memcached.so /usr/lib/php5/20090626+lfs/memcached.so

and my php.ini file is located at /etc/php5/apache2/php.ini 我的php.ini文件位于/etc/php5/apache2/php.ini

the phpinfo() php function (just place in a file and view it) also reveals memcache as supported and loaded "memcached support enabled" (I specifically used memcached extension, not memcache) phpinfo()php函数(只是放在一个文件中并查看它)也显示memcache为支持和加载“memcached支持启用”(我专门使用memcached扩展,而不是memcache)

mind you that your webserver might be configured to use a different php.ini path (and thus file) than your command line, so verify both. 请注意,您的Web服务器可能配置为使用与命令行不同的php.ini路径(以及文件),因此请同时验证两者。 Also make sure you place the extension=memcache.so in the correct location, since many distros place it in /etc/php5/conf.d/memcache.ini might be there's some discrepancy there? 还要确保将extension = memcache.so放在正确的位置,因为许多发行版将它放在/etc/php5/conf.d/memcache.ini中可能会有一些差异吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Memcache&php:致命错误:未找到类'Memcache' - Memcache & php: Fatal error: Class 'Memcache' not found in 致命错误:未找到类“Memcache” - Fatal error: Class 'Memcache' not found in 致命错误:找不到类“ Memcache” - Fatal error: Class 'Memcache' not found PHP memcached 致命错误:找不到“Memcache”类 - PHP memcached Fatal error: Class 'Memcache' not found Drupal —致命错误:找不到类“ Memcache” - Drupal — Fatal error: Class 'Memcache' not found 即使安装了memcache扩展,在wordpress的object-cache.php中也出现了“ PHP致命错误:找不到类'Memcache'” - “PHP Fatal error: Class 'Memcache' not found” occurred in object-cache.php of wordpress even after installed memcache extension 在Windows Server上安装memcached时出现“致命错误:找不到类'Memcache'” - “Fatal error: Class 'Memcache' not found” when installing memcached on Windows Server 致命错误:在Zend Framework + Wamp中找不到类“ Memcache” - Fatal error: Class 'Memcache' not found in Zend Framework + Wamp “尝试在Ubuntu中安装Memcache时发生致命错误:类'Memcached'未找到” - “Fatal error: Class 'Memcached' not found” when trying to install Memcache in Ubuntu 致命错误:即使在php.ini中加载了pecl_http之后,也找不到类'HttpResponse' - Fatal error: Class 'HttpResponse' not found even after pecl_http loaded in php.ini
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM