How To Install Memcache PHP Extension

by lifeLinux on August 23, 2011

Memcache extension provides handy procedural and object oriented interface to memcached, highly effective caching daemon, which was especially designed to decrease database load in dynamic web applications. This article will explain how to install the memcache PHP extension on Centos/RedHat/Fedora.

The first, download the latest & stable package from http://pecl.php.net/package/memcache. Type the following command

# wget http://pecl.php.net/get/memcache-2.2.6.tgz

Extract memcache-2.2.6.tgz

# tar zxvf memcache-2.2.6.tgz

To install memcache extension, you need to install the php-devel package that matches the version of php that you are currently running. Example, i’m using PHP 5.3 then enter

# yum install php53-devel

Run the phpize command to prepare the build environment for a PHP extension

# phpize

Sample output

Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626

Configure & Install memcache extension. Type the following command

# ./configure
# make
# make install

If your get the following error message when run ./configure

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

Then type the following command to fix it

# yum install zlib zlib-devel

Finally, use the following command to add memcache extension to php.ini

# echo "extension=memcache.so" >> /etc/php.ini

Related Posts:

Previous post:

Next post: