Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memcached installed but class not found

Tags:

php

memcached

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 with sudo pecl install memcached

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

$mc = new Memcached();

gets:

Fatal error: Class 'Memcached' not found

Never used PECL as an install mechanism before, do I need to do something extra in php.ini or somewhere to be able to use the class?

like image 394
Steve Claridge Avatar asked Oct 28 '10 20:10

Steve Claridge


2 Answers

It's possible that it didn't install correctly or, as you say, you might need to add the following to php.ini: extension = memcached.so

But since you say it shows up in phpinfo() it seems more likely that it just didn't install correctly. Were there any errors in the output during installation?

Also, to state the obvious, make sure you've restarted your server.

I wrote up a tutorial on getting memcached running on Ubuntu, which I mention not to self-promote, but just in case it's helpful.

like image 132
stevelove Avatar answered Sep 21 '22 08:09

stevelove


There is often a lot of confusion between 'Memcached' and 'Memcache'. It might be worth installing both to eliminate any such problems. You can use the following to install 'Memcache'

sudo apt-get install php5-memcache
like image 28
Phill Healey Avatar answered Sep 22 '22 08:09

Phill Healey