Posts Tagged ‘CentOS’

Posted by 6bytes at 13, March, 2010

Category: CentOS, Linux, PHP

Tags: , , ,

After installing memcached daemon we have to install memcache PHP extension.

yum install php-pecl-memcache


apt-get install php5-memcache

If above is not an option try below method.

pecl install memcache

After successful installation add extension to your php.ini file.

vim /etc/php.ini

Add this line:

Restart web server

service httpd restart

Test out our installation.

$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ('Can\'t connect!');
$version = $memcache->getVersion();
echo 'Server version: '.$version;

You should see your server’s version number. If you see a blank page make sure that memcached daemon is working. If you’re getting “Can’t connect!” message despite running daemon try changing ‘localhost’ to ‘’.

Posted by 6bytes at 13, March, 2010

Category: CentOS, Linux

Tags: , , , ,

Before we install memcached we need a dependency library libevent. Check for latest stable version at

cd /usr/local/src
tar -xzvf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure --prefix=/usr/local
make install
cd ..

Now lets install memcached. Check for latest stable version at

tar -xzvf memcached-1.4.4.tar.gz
cd memcached-1.4.4
LDFLAGS='-Wl,--rpath /usr/local/lib' ./configure --prefix=/usr/local
make install

More information about LDFLAGS

Run memcached as a daemon. Basic options: d = daemon, m = memory, u = user, l = IP to listen to, p = port

memcached -u root -d


memcached -u root -d -m 512 -l -p 11211

To stop daemon type

pkill memcached

Now we’re off to installing php extension memcache.