Re: (nginx) fcgi+PHP+memcache on RedHat: Class 'Memcache' not found...
| From: | Eddie Drapkin | Date: | Mon, 26 Oct 2009 16:25:15 +0000 |
| Subject: | Re: (nginx) fcgi+PHP+memcache on RedHat: Class 'Memcache' not found... | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-299353@lists.php.net to get a copy of this message | ||
On Mon, Oct 26, 2009 at 12:22 PM, Tom Barrett <tom@miramedia.co.uk> wrote:
> 2009/10/26 Eddie Drapkin <oorza2k5@gmail.com>:
>> On Mon, Oct 26, 2009 at 11:59 AM, Tom Barrett <tom@miramedia.co.uk> wrote:
>>> 2009/10/26 Eddie Drapkin <oorza2k5@gmail.com>:
>>>> On Mon, Oct 26, 2009 at 11:45 AM, Tom Barrett <tom@miramedia.co.uk> wrote:
>>>>> Hello
>>>>>
>>>>> I have installed:
>>>>> - libevent
>>>>> - libmemcached (http://tangent.org/552/libmemcached.html)
>>>>> - Done a PECL installation (pecl download memcached, phpize &&
>>>>> ./configure && make)
>>>>> - memcached
>>>>>
>>>>>> cat /etc/php.d/memcached.ini
>>>>> ; Memcached default settings
>>>>> extension=memcache.so
>>>>>
>>>>>> ls -1 /usr/lib64/php/modules/memcache*
>>>>> /usr/lib64/php/modules/memcached.so
>>>>> /usr/lib64/php/modules/memcache.so
>>>>>
>>>>>> memcached -h
>>>>> memcached 1.2.6
>>>>> ...
>>>>>
>>>>>> php -v
>>>>> PHP 5.1.6 (cli) (built: Feb 26 2009 07:01:12)
>>>>> Copyright (c) 1997-2006 The PHP Group
>>>>> Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
>>>>>
>>>>>
>>>>> /var/www/php_fcgi_memcache> cat memcache.php
>>>>> <?php
>>>>> $memcache = new Memcache;
>>>>> print_r($memcache);
>>>>> ?>
>>>>>
>>>>> /var/www/php_fcgi_memcache> php memcache.php
>>>>> PHP Fatal error: Class 'Memcache' not found in
>>>>> /var/www/php_fcgi_memcache/memcache.php on line 2
>>>>>
>>>>> Memcached is working fine (being use by Perl quite happily).
>>>>>
>>>>> PHP/FCGI is working OK and phpinfo() shows:
>>>>> memcached support enabled
>>>>> Version 1.0.0
>>>>> libmemcached version 0.34
>>>>> Session support yes
>>>>>
>>>>> Any pointers in the right direction would so very much appreciated.
>>>>>
>>>>> --
>>>>> PHP General Mailing List (http://www.php.net/)
>>>>> To unsubscribe, visit:
>>>>> http://www.php.net/unsub.php
>>>>>
>>>>>
>>>>
>>>> Try instantiating a Memcached instance, not a Memcache instance.
>>>> They're two different PECL extensions!
>>>
>>> Hi
>>>
>>> That just auto-instantiates an empty object?
>>>
>>>> cat memcached.php
>>> <?php
>>> $memcache = new Memcached;
>>> print_r($memcache);
>>> ?>
>>>
>>>> php memcached.php
>>> Memcached Object
>>> (
>>> )
>>>
>>> I have used the $m=new Memcache; syntax on another server, which works fine.
>>>
>>> Or have I mixed up my libraries somehow?
>>>
>>
>> They're actually two different classes from two different PECL
>> extensions. Memcached is the newer (imo better) extension written by
>> Andrei (at digg) to use libmemcached. Memcache is the older, entirely
>> custom (no external deps) PECL extension that's been around forever.
>> So, I'm guessing you have Memcache on one machine and Memcached on
>> another. They have slightly different APIs, so I'd make sure you're
>> aware of which one you're using. :)
>
> Thanks
>
> Any chance you could show me the way?
>
> This is how I installed the PECL extension:
>
>> pecl download memcached
>> tar zxf memcached-1.0.0.tgz
>> cd memcached-1.0.0
>> phpize
>> ./configure
>> make
>> make install
>
> Does that look like the right one? Did I miss something?
>
That'll install the Memcached extension, which is the one I'd usually
recommend and the one that I use. I don't see anythign wrong with
using that one or that way of installing it, but I was just saying
that the method names and parameters are different from the older
extension and to just be aware of that.
Old extension: http://us2.php.net/manual/en/book.memcache.php
New extension: http://us2.php.net/manual/en/book.memcached.php
The naming confusion is unnecessary but it exists so there's not
really too much you can do about it :P