PHP Fatal error: Class ‘Memcache’ not found in

This is the general PHP error that occurs in the website when the Memcache module is missing. Thinking to install memcache via easy apache. Really it is a bad idea.

I too tried to install memcache module via easyapache. Every time in the easy apache it shows the memcache is enables. However, once the the compiling is complete, memcache module is not compiled in the php.

What is the solution for this error “PHP Fatal error: Class ‘Memcache’ not found in ‘/home/user/hemanth/php.ini’ ?

The only solution is to compile memcache module via source and add the link in the php.ini. Just follow the steps below to compile memcache module in the server.

Step 1 – Download memcache



mkdir repo
cd repo
wget http://pecl.php.net/get/memcache-3.0.6.tgz
tar -xvfz memcache-3.0.6.tgz




Step 2 – Compilation & installation

cd memcache-3.0.6
phpize
you should see something like this;

Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519

./configure
make
make install



Step 3 – Load in php.ini
Enable memcache in php.ini.

echo "extension=memcache.so" >> /usr/local/lib/php.ini
service httpd restart





++++++++++++++++++++++++++++++


This is how it will look like when you try to install the Memcache in the cPanel.


root@server [~]# mkdir repo
root@server [~]# cd repo
root@server [~/repo]# wget http://pecl.php.net/get/memcache-3.0.6.tgz
--2012-02-29 17:03:30--  http://pecl.php.net/get/memcache-3.0.6.tgz
Resolving pecl.php.net... 76.75.200.106
Connecting to pecl.php.net|76.75.200.106|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 54717 (53K) [application/octet-stream]
Saving to: `memcache-3.0.6.tgz'

100%[===================================================================================>] 54,717      16.9K/s   in 3.2s   

2012-02-29 17:03:34 (16.9 KB/s) - `memcache-3.0.6.tgz' saved [54717/54717]

root@server [~/repo]#

root@server [~/repo]# tar -zxvf memcache-3.0.6.tgz
package.xml
memcache-3.0.6/config.m4
memcache-3.0.6/config9.m4
memcache-3.0.6/config.w32
memcache-3.0.6/CREDITS
memcache-3.0.6/example.php
memcache-3.0.6/memcache.c
memcache-3.0.6/memcache_pool.c
memcache-3.0.6/memcache_queue.c
memcache-3.0.6/memcache_session.c
memcache-3.0.6/memcache_ascii_protocol.c
memcache-3.0.6/memcache_binary_protocol.c
memcache-3.0.6/memcache_standard_hash.c
memcache-3.0.6/memcache_consistent_hash.c
memcache-3.0.6/memcache.dsp
memcache-3.0.6/php_memcache.h
memcache-3.0.6/memcache_pool.h
memcache-3.0.6/memcache_queue.h
memcache-3.0.6/README
memcache-3.0.6/memcache.php
root@server [~/repo]#
root@server [~/repo]# cd memcache-3.0.6
root@server [~/repo/memcache-3.0.6]# phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
root@server [~/repo/memcache-3.0.6]#
root@server [~/repo/memcache-3.0.6]# make install
Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20060613/
root@server [~/repo/memcache-3.0.6]# echo "extension=memcache.so" >> /usr/local/lib/php.ini
root@server [~/repo/memcache-3.0.6]#
root@server [~/repo/memcache-3.0.6]# service httpd restart
root@server [~/repo/memcache-3.0.6]#
root@server [~/repo/memcache-3.0.6]#
root@server [~/repo/memcache-3.0.6]#
root@server [~/repo/memcache-3.0.6]# php -i |grep php.ini
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini
root@server [~/repo/memcache-3.0.6]#
root@server [~/repo/memcache-3.0.6]# php -m |grep memcache
memcache
root@server [~/repo/memcache-3.0.6]#




Leave a Reply