简体   繁体   中英

Drupal — Fatal error: Class 'Memcache' not found

I have installed drupal on my localhost. It worked well 2 months ago, but now something happened and I don't know why. I'll be very grateful if you can help me. Thanks in advance.

The full error looks like this:

Fatal error: Class 'Memcache' not found in /srv/www/htdocs/modules/memcache/dmemcache.inc on line 177

1) php -m gives this:

[PHP Modules]
bz2
ctype
date
dom
filter
gd
hash
iconv
json
libxml
mbstring
mcrypt
mysql
mysqli
pcre
PDO
pdo_mysql
pdo_sqlite
Reflection session SimpleXML SPL SQLite standard sysvsem tokenizer xml xmlreader xmlwriter zip zlib

[Zend Modules] none

2) memcached is installed through package manager.

3) memcache module for drupal installed

what am I doing wrong? thx.

I convene with googletorp that the problem seems to rely on memcache installation. Try this:

#if apt-get, rpm, or yum doesn't work
cd /usr/src/
wget http://pecl.php.net/get/memcache-2.2.4.tgz
tar -zxvf memcached-2.2.4.tgz
cd memcached-2.2.4
phpize && ./configure --enable-memcache && make
cp modules/memcache.so /usr/lib/php/modules/

# Note: packaged extension modules are now loaded via the .ini files
# found in the directory /etc/php.d
touch /etc/php.d/memcached.ini
echo 'extension=memcache.so' > /etc/php.d/memcached.ini

service httpd restart

The above procedure has been brutally copied from the comments to the page of the official memecache documentation . It is dated 11.12.09.

A co-worker helped me today with this issue, I use Drupal & Drush (command line tool), and sometimes MAMP.

Try:

echo $PHPRC

If it comes up blank then save this in your ~/.profile or your *~/.bash_profile* config file:

export PHPRC='/Library/Application Support/appsolute/MAMP PRO/conf/php.ini'

Thank you very much for your answers -- I've eventually managed with this problem. Here's the solution as for openSUSE 11.1.

  1. Install memcache extension for php :

     #if apt-get, rpm, or yum doesn't work cd /usr/src/ wget http://pecl.php.net/get/memcache-2.2.5.tgz tar -zxvf memcache-2.2.5.tgz cd memcache-2.2.5 phpize5 ./configure --enable-memcache make make install cp modules/memcache.so /usr/lib/php5/extensions/ # Note: packaged extension modules are now loaded via the .ini files # found in the directory /etc/php5/conf.d/ touch /etc/php5/conf.d/memcache.ini echo 'extension=memcache.so' > /etc/php5/conf.d/memcache.ini 

    now you should restart apache2 service

  2. Install memcached daemon for php and run it as a daemon.

  3. Install memcache plugin for drupal (all instructions here: http://drupal.org/project/memcache )

UPD . be carefull with upgrading PHP: intalled modules might not be working well with new version -- you should recompile them. but somehow "pear install -f pecl/memcache" did the trick for me :)

It seems your memcache drupal module is expecting a class to be available in the inc file mentioned.

  • Did you upgrade your drupal module?
  • In such cases it's good to look at the issue que for the module on drupal.org.

It looks like it's the drupal module that's the problem. My guess an upgrade went wrong.

EDIT:
I Took at look at the module, I was on my iphone, so couldn't look through the code. Your problem is that Drupal can't find the Memcache class. This fix is defined in step two of the installation process.

2. Install the PECL memcache extension for PHP. This must be version 2.2.1 or higher or you will experience errors.

Either you are missing this now, or something is wrong with the installation. In any regard, Drupal can't find the Memcache that is defined in this extension, and that is why you get the fatal error.

It might be enough to just add extension=memcached.so to your php.ini . The location of this file can be found using phpinfo();

Make sure you restart apache afterwards.

my take is that memecache may be installed on your machine, but it's not correctly compiled with PHP had this issue before with memecache. check here for more details

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM