在命令行 PHP 脚本中找不到“Memcache" [英] 'Memcache' not found in command line PHP script

查看:32
本文介绍了在命令行 PHP 脚本中找不到“Memcache"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了 Memcache 并为通过 Apache (v2.2) 运行的 PHP 应用程序工作,但是当我尝试在命令行中运行 .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
阿帕奇 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

推荐答案

大概你已经为 apache 和命令行 (cli) 设置了单独的 php.ini 文件.

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

如果它正常工作,那么如果您在命令行上运行 php -m,内存缓存应该出现在模块列表中.

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屋!

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