Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
732 views
in Technique[技术] by (71.8m points)

apache - 'Memcache' not found in command line PHP script

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

Line 94 is:

$memcache = new Memcache;

Other info:

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Presumably you have separate php.ini files set up for apache and the command line (cli).

If so, you need to add the following to your cli php.ini file:

extension=memcache.so

On Ubuntu it's in /etc/php5/cli/php.ini

If it's working then memcache should appear in the list of modules if you run php -m on the command line.

Alternatively, you can create a file /etc/php5/cond.d/memcache.ini with the same contents.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...