memcached

How to install Memcache on Linux RHEL6.2?

$yum install memcached

Most important value to configure is CACHESIZE, which is cache size on Megabytes. Example Following configuration use 512 Mb memory for Memcached

$vi /etc/sysconfig/memcached

change CACHESIZE to 512, i.e. CACHESIZE=”512″

# Set Memcached to start automatically on boot

$chkconfig memcached on

# Start Memcached

$/etc/init.d/memcached start

## OR ##

$service memcached start

To check the version of Memcached

$memcached -h

#install zlib package if not installed, I have to do that

$wget http://www.zlib.net/zlib-1.2.5.tar.gz ( Go to http://www.zlib.net/ and take the latest version)
$tar xvfz zlib-1.2.5.tar.gz
$cd zlib-1.2.5
$./configure
$make
$make install
$wget http://pecl.php.net/get/memcache-2.2.5.tgz
$tar xvfz memcache-2.2.5.tgz
$cd memcache-2.2.5
$phpize

(phpize:Command not found case, run yum install php-devel then YES)
Again

$phpize
$./configure –enable-memcache
$make
$make install

#search for PHP.ini file, if you donot know

$php -i | grep php.ini
Configuration File (php.ini) Path => /etc/
Loaded Configuration File => /etc/php.ini
$vi /etc/php.ini
#Add the following into PHP ini file
[code lang="bash"]
extension = memcache.so

#restart apache

$/etc/init.d/httpd restart

or

$service httpd restart

#To check is memcache extension loaded in php, execute following command.

$php -i | grep memcache
#you will get the output like
memcache
memcache support => enabled
memcache.allow_failover => 1 => 1
memcache.chunk_size => 8192 => 8192
memcache.default_port => 11211 => 11211
memcache.default_timeout_ms => 1000 => 1000
memcache.hash_function => crc32 => crc32
memcache.hash_strategy => standard => standard
memcache.max_failover_attempts => 20 => 20
Registered save handlers => files user sqlite memcache
PWD => /usr/src/memcache-2.2.5
_SERVER["PWD"] => /usr/src/memcache-2.2.5
_ENV["PWD"] => /usr/src/memcache-2.2.5

#you can also check this information using phpinfo() in php.