Solved

PHP and memcache -- getting started

Posted on 2014-12-10
17
98 Views
Last Modified: 2014-12-11
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!
0
Comment
Question by:Daniel Wilson
  • 10
  • 7
17 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40493092
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
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 40493094
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.
0
 
LVL 58

Expert Comment

by:Gary
ID: 40493097
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
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 40493104
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.*
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 40494066
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
0
 
LVL 58

Expert Comment

by:Gary
ID: 40494178
Do the phpinfo as above and check it is listed.
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 40494230
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?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40494250
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.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 32

Author Comment

by:Daniel Wilson
ID: 40494271
OK, it's not being loaded.

How do I get it to be loaded?
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 40494310
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 ...
0
 
LVL 58

Expert Comment

by:Gary
ID: 40494315
Is that from running

apt-get install memcached
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 40494335
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.
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 40494357
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
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40494378
0
 
LVL 32

Author Closing Comment

by:Daniel Wilson
ID: 40494909
No doubt that's the right answer.  Not working on Ubuntu 8.04.4 LTS.  Server upgrade has been planned for a while ...
0
 
LVL 58

Expert Comment

by:Gary
ID: 40494925
Yeah, thats quite an old version and really should have been updated 2 years ago.
0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 40494931
True.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
object oriented programming comparison 5 57
WordPress Themes 10 35
PHP preg_replace code convert to Delphi 14 39
php convert date format 3 0
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses how to create an extensible mechanism for linked drop downs.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now