PHP扩展(memcache | memcached)不是显示在phpinfo()中,而是显示在php -m和php -i中? [英] PHP Extension (memcache|memcached) not showing in phpinfo() but showing in php -m and php -i?

查看:308
本文介绍了PHP扩展(memcache | memcached)不是显示在phpinfo()中,而是显示在php -m和php -i中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用时,我将两个模块都列为已安装/已配置:

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

php -m

或者如果我使用:

php -i

但是当我使用时:

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

我收到以下错误:

Fatal error: Class 'Memcached' not found

我在Mac上运行-OS X(10.5.7),默认安装了apache&的PHP.另外,我还按照php-memcached库的要求在127.0.0.1:11211上将memcached作为守护程序运行,并使用libmemcache.我已经重启了很多次apache,甚至重启了机器.

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.

有人知道为什么模块/扩展名显示在命令行中而不显示在我的phpinfo()中吗?在经过三个小时的谷歌搜索后,我实在感到沮丧,我正准备放弃.

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.

另外,请注意,我的phpinfo()输出我的ini文件,如下所示,它们都是完全相同的文件:

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 

更新:

Apache无法加载扩展.

Apache is failing to load the extension.

[2010年5月14日星期五04:22:26] [警告] 初始化:未配置会话缓存 [提示:SSLSessionCache] PHP警告: PHP启动:无法动态加载 图书馆 '/usr/lib/php/extensions/no-debug-non-zts-20060613/memcached.so' -(null)在第0行上的Unknown中PHP警告:PHP启动:无法加载 动态库 '/usr/lib/php/extensions/no-debug-non-zts-20060613/memcache.so' -(null)在第0行的Unknown中

[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?

推荐答案

您的网络服务器可能正在使用mod_php,这是独立(CLI)解释器的另一部分代码.如果它们都使用同一个ini文件,并且ini文件中配置了memcache扩展名,则听起来由于某种原因,mod_php无法加载该扩展名-请检查您的网络服务器error_log中的启动错误.

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.

可能是mod_php是在没有内存缓存支持的情况下编译的(大多数扩展需要将存根文件链接到php代码中,即使大部分代码直到运行时才链接).或它可能是共享库文件上的权限问题.或者您的网络服务器可能正在运行chroot,并且无法找到扩展名(这也意味着,尽管ini文件看起来具有相同的路径,但这是相对于不同的根目录的.)

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.

这篇关于PHP扩展(memcache | memcached)不是显示在phpinfo()中,而是显示在php -m和php -i中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆