Link to home
Start Free TrialLog in
Avatar of Daniel Wilson
Daniel WilsonFlag for United States of America

asked on

PHP and memcache -- getting started

The PHP memcache example is not working for me.
http://php.net/manual/en/memcache.examples-overview.php

Fatal error: Class 'Memcache' not found

I suspect I need to require_once something.

I'm running PHP 5.2.4 and phpinfo() reports /etc/php5/apache2/conf.d/memcache.ini in the "additional .ini files parsed"

what am I failing to do?

Thanks!
Avatar of Gary
Gary
Flag of Ireland image

What exactly are you trying to do
In php there is Memcache and Memcached - you are probably trying to reference the wrong one - but there could be a dozen different reasons for the error
Avatar of Daniel Wilson

ASKER

I am attempting to cache a result set from MySql.

But ... to get there, I am attempting to follow the example so I can do SOMETHING with memcache or memcached.
Do a phpinfo() to be sure what you are using

Either memcache or memcached is not installed or they are not enabled in php.ini
The line in "additional.ini files" is the only reference to memcache in phpinfo()

Build Date       Mar 11 2013 14:04:25
Server API       Apache 2.0 Handler
Virtual Directory Support       disabled
Configuration File (php.ini) Path       /etc/php5/apache2
Loaded Configuration File       /etc/php5/apache2/php.ini
Scan this dir for additional .ini files       /etc/php5/apache2/conf.d
additional .ini files parsed       /etc/php5/apache2/conf.d/APC.ini, /etc/php5/apache2/conf.d/gd.ini, /etc/php5/apache2/conf.d/memcache.ini, /etc/php5/apache2/conf.d/mysql.ini, /etc/php5/apache2/conf.d/mysqli.ini, /etc/php5/apache2/conf.d/pdo.ini, /etc/php5/apache2/conf.d/pdo_mysql.ini
PHP API       20041225
PHP Extension       20060613
Zend Extension       220060519
Debug Build       no
Thread Safety       disabled
Zend Memory Manager       enabled
IPv6 Support       enabled
Registered PHP Streams       zip, php, file, data, http, ftp, compress.bzip2, compress.zlib, https, ftps
Registered Stream Socket Transports       tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
Registered Stream Filters       string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, convert.iconv.*, bzip2.*, zlib.*
So is there a connecting piece I must install?

Here's what my system reports at the command-line:
:~$ apt-cache search memcache
collectd - statistics collection and monitoring daemon
libcache-memcached-perl - Cache::Memcached - client library for memcached
libmemcache-dev - development headers for libmemcache C client API
libmemcache0 - C client API for memcached memory object caching system
php5-memcache - memcache extension module for PHP5
python-myghtyutils - Set of utility classes used by Myghty templating
memcached - A high-performance memory object caching system
Do the phpinfo as above and check it is listed.
Check what is listed?  What I've been trying to explain is that the only listing of anything memcache is in the snippet I posted in the "additional .ini files parsed " section.

Maybe I'm asking the wrong question.

What do I need to install so that I can use memcache or memcached from PHP?
phpinfo() will list all loaded libraries, if it's not listed there then it is not being loaded
There is no point going any further til we know that.
OK, it's not being loaded.

How do I get it to be loaded?
Some pages recommend something with pecl.  But pecl is complaining about my PHP version.  I'm running PHP 5.2.4 on Ubuntu 8.  That may be part of the problem, but memcached has been around a LONG time ...
Is that from running

apt-get install memcached
yes, I did install memcached in that way.

So apt-get reports memcached is at the newest version.

However ... ps-A | grep memcach returns nothing.
For what it's worth, the top comment here has an example that fails similarly for me:
http://php.net/manual/en/memcached.installation.php
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No doubt that's the right answer.  Not working on Ubuntu 8.04.4 LTS.  Server upgrade has been planned for a while ...
Yeah, thats quite an old version and really should have been updated 2 years ago.
True.