Memcached installed but class not found

If I run phpinfo (), it tells me that memcached is installed.

memcached memcached support enabled Version 1.0.2 libmemcached version 0.44 Session support yes igbinary support no 

I installed it using sudo pecl install memcached

But when I try to instantiate the memcached class, it was not found:

$ mc = new Memcached ();

gets:

Fatal error: Class 'Memcached' not found

PECL has never been used as an installation mechanism before, do I need to do something in php.ini or somewhere to be able to use the class?

+7
php memcached
source share
2 answers

It may not be installed correctly or, as you say, you may need to add the following to php.ini: extension = memcached.so

But, since you say this is displayed in phpinfo (), it seems more likely that it just isn't installed correctly. Were there any errors in the output during installation?

Also, to indicate the obvious, make sure you restart the server.

I wrote a tutorial on how to run memcached on Ubuntu , which I mention not for self-learning, but just in case it is useful.

+12
source share

There is often a lot of confusion between Memcached and Memcache. It may be worthwhile to establish how to fix such problems. To install Memcache

you can use the following:
 sudo apt-get install php5-memcache 
+1
source share

All Articles