Memcache module provides handy procedural and object oriented interface to memcached highly effective caching and its task is decrease database load in dynamic web application

We have already installed XAMPP on the previous post so configure memcache

Note : While installation If you may getting an any  errors  the solutions are given on this post.

Download memcache and extract that file

# wget

# tar xf memcache-3.0.8.tgz

# cd memcache-3.0.8

Configure memcache :
# /opt/lampp/bin/phpize

Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525
# ./configure --enable-memcache --with-php-config=/opt/lampp/bin/php-config

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h.
# make && make install

Installing shared extensions:

Open php.ini configure file Add memcache extension
# vi /opt/lampp/etc/php.ini


close vi with :wq!

Install memcached on your system using yum or apt-get

# yum install memcached

# apt-get install memcached

Start memcache service on system at boot time
# chkconfig --levels 235 memcached on

# /etc/init.d/memcached start

To ensure whether the service is running or not
# ps -eaf | grep memcached

memcache 22933  1744  0 16:09 ?        00:00:00 /usr/bin/memcached -m
64 -p 11211 -u memcache -l

To check may have memcached  installed in the system by phpinfo() function, create a php file with name test.php with below simple code,
echo phpinfo();

Also, check with command on terminal,
#    /opt/lampp/bin/php  -i  |  grep memcache

memcache support => enabled
memcache.allow_failover => 1 => 1
memcache.chunk_size => 32768 => 32768
memcache.compress_threshold => 20000 => 20000
memcache.default_port => 11211 => 11211
memcache.hash_function => crc32 => crc32
memcache.hash_strategy => consistent => consistent
memcache.lock_timeout => 15 => 15
memcache.max_failover_attempts => 20 => 20
memcache.protocol => ascii => ascii
memcache.redundancy => 1 => 1
memcache.session_redundancy => 2 => 2
Registered save handlers => files user memcache

If you may face an error as same as below,

Error 1 :
#  /opt/memcache-3.0.8# /opt/lampp/bin/phpize

Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.


Autoconf and supporting packages does not find in your system  follow the steps to be installed
# cd /usr/src

# wget

# tar -zvxf m4-1.4.9.tar.gz

# cd m4-1.4.9/

# ./configure && make && make install

# cd ../

# wget

# tar -zvxf autoconf-2.62.tar.gz

# cd autoconf-2.62/

# ./configure && make && make install

# memcached -d

Error 2 :
#  /opt/lampp/bin/phpize

grep: /opt/lampp/include/php/main/php.h: No such file or directory
grep: /opt/lampp/include/php/Zend/zend_modules.h: No such file or directory
grep: /opt/lampp/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:        
Zend Module Api No:     
Zend Extension Api No: 


xmapp-devel package does not found in your XMAPP, download devel package :
# cd /opt

# wget

If you have extracted on the same directory files will be replicated on the lampp
# tar -xf xampp-linux-devel-1.6.6.tar.gz


Error 3 :
# ./configure --enable-memcache --with-php-config=/opt/lampp/bin/php-config

checking for the location of ZLIB... no
checking for the location of zlib... configure: error: memcache support requires ZLIB. Use --with-zlib-dir=
to specify prefix where ZLIB include and library are located


Install libgcrypt11-dev and zlib1g-dev packages in your system,
# apt-get install libgcrypt11-dev

# apt-get install zlib1g-dev