Install Memcached And PHP5-MemCached Module On Debian 6.0 (Squeeze)
"Memcached is free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load."
More information about memcached can be found at http://www.memcached.org/
This article is going to explain how to install memcached and PHP5-MemCached module on a Debian 6.0(Squeeze) system with Apache2.
apt-get install memcached php5-memcached
"apt-get" is a very powerful command-line tool for handling packages. Here is a tip about how to use "apt-get", take this situation as an example: I'm going to install Memcached and php module associated with it, but I'm not quite sure about the exact name of the packages, then we can use the following command to search the available package lists:
apt-cache search memcache
Then you will find something like this:
memcached - A high-performance memory object caching system
memcachedb - Persistent storage engine using the memcache protocol
php5-memcache - memcache extension module for PHP5
php5-memcached - memcached extension module for PHP5
You should find both php5-memcache and php5-memcached, php5-memcached is newer and has sessions support. Here I'm going to use php5-memcached.
2.1 Testing Memcached
After the installation, memcached should already be running. You can have a check by using the following command:
netstat -tap | grep memcached
Usually you will get something like this:
tcp 0 0 localhost:11211 *:* LISTEN 2132/memcached
You can change its configuration by modifying the file /etc/memcached.conf.
2.2 Testing PHP5-Memcached Module
First you need restart Apache web server,
Create a php file which accessible from web and copy the content to the file:
Then use browser to open the php file to check result.
For more detail please check http://www.php.net/manual/en/book.memcached.php, here is a simple example:
$m = new Memcached();
$m->set('key', 'hello world');