Saturday, August 14, 2010

? Memcached in Ubuntu Server 10.04

Memcache is a very simple caching system that uses memory to store objects. As you may already know, memory is faster to read than hard drive. A site will take a lot less time to read a database result cached in memory. To make the best use of memcache, you should install the memcached module. 


First, install the apache2, memcached package, php-pear , php5-dev and libmemcached-de


Install the following in the below order. 
sudo apt-get install memcached
sudo apt-get install php-pear
sudo apt-get install php5-dev
sudo apt-get install libmemcached-dev
sudo pecl install Memcache


and 
sudo echo "extension=memcache.so" >/etc/php5/apache2/conf.d/memcache.ini


Add the following line anywhere, to your php.ini file.
memcache.hash_strategy="consistent"


Start an instance of memcache daemon with the following command:
memcached -d -m 2048 -l 127.0.0.1 -p 11211


If you are only using a single server, then you only need to include this line to your site’s settings.php file.
$conf['cache_inc'] = '/sites/all/modules/memcache/memcache.inc';


The final step is to restart apache and then switch your site back online.





Following command helps to get the connection status :
 $netstat -na | grep 11211




No comments:

Post a Comment