Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Extension (memcache|memcached) not showing in phpinfo() but showing in php -m and php -i?

Tags:

php

memcached

I am getting both modules listed as installed / configured when I use:

php -m

or if I use:

php -i

but when I use:

$m = new Memcache;
// or
$m = new Memcache();
// or
$m = new Memcached();
//or 
$m = new Memcached;

I get the following error:

Fatal error: Class 'Memcached' not found

I am running on a Mac - OS X (10.5.7) with default install of apache & php. Additionally, I have memcached running as a daemon on 127.0.0.1:11211 and libmemcache as required by the php-memcached library. I have restarted apache tons of times and even done a machine restart.

Does anyone know why the modules/extensions show up in the command line but not in my phpinfo()? I am literally stumped, after 3 hours of googling, I am just about ready to give up.

Also, please note, my phpinfo() outputs my ini files as follows AND they are both the exact same file:

Configuration File (php.ini) Path:  /etc
Loaded Configuration File:  /private/etc/php.ini 

UPDATE:

Apache is failing to load the extension.

[Fri May 14 04:22:26 2010] [warn] Init: Session Cache is not configured [hint: SSLSessionCache] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20060613/memcached.so' - (null) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20060613/memcache.so' - (null) in Unknown on line 0

Does anyone know why or how this would happen? Both of the files referenced above DEFINITELY ARE there. Should I move this question to server fault?

like image 410
Auston Avatar asked May 14 '10 07:05

Auston


2 Answers

Your webserver is probably using mod_php, which is a seperate bit of code from the standalone (CLI) interpreter. If they are both using the same ini file, and the memcache extension is configured in the ini file, then it sounds like for some reason, the mod_php is failing to load the extension - check your webserver error_log for startup errors.

It may be that the mod_php was compiled without memcache support (most extensions need to have a stub file linked into the php code, even though the bulk of the code is not linked until run time). Or it may be a permissions problem on the shared object file. Or your webserver may be running chroot, and unable to find the extension (which would also mean that although the ini files appear to have the same path, this is relative to different roots).

HTH

C.

like image 56
symcbean Avatar answered Nov 13 '22 06:11

symcbean


because both versions use different php.ini
place your php.ini into location noted in the phpinfo() outout

like image 3
Your Common Sense Avatar answered Nov 13 '22 05:11

Your Common Sense