在命令行PHP脚本中找不到“Memcache” [英] 'Memcache' not found in command line PHP script
问题描述
我有Memcache安装和PHP应用程序运行通过Apache(v2.2),但是当我尝试在命令行运行一个.php文件时,我得到这个错误:
I have Memcache installed and working for PHP apps run through Apache (v2.2) but when I try to run a .php file in the command-line i get this error:
Fatal error: Class 'Memcache' not found in /usr/local/Matters/app/matters-common/connection.php on line 94
第94行是:
$memcache = new Memcache;
其他信息:
CentOS 5.2
PHP 5.2.5(cli)(内置:2008年2月20日21:13:12)
Zend Engine v2.2.0,版权所有(c)1998 -2007 Zend Technologies
Apache v2.2.8
CentOS 5.2
PHP 5.2.5 (cli) (built: Feb 20 2008 21:13:12)
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
Apache v2.2.8
推荐答案
大概你有单独的php.ini文件设置对于apache和命令行(cli)。
Presumably you have separate php.ini files set up for apache and the command line (cli).
如果是这样,您需要将以下内容添加到cli php.ini文件中:
If so, you need to add the following to your cli php.ini file:
extension=memcache.so
在Ubuntu上它在/etc/php5/cli/php.ini
On Ubuntu it's in /etc/php5/cli/php.ini
如果它工作,那么memcache应该出现在模块列表中,如果你运行
If it's working then memcache should appear in the list of modules if you run php -m
on the command line.
或者,您可以创建一个文件 / etc / php5 / cond。 d / memcache.ini
与相同的内容。
Alternatively, you can create a file /etc/php5/cond.d/memcache.ini
with the same contents.
这篇关于在命令行PHP脚本中找不到“Memcache”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!