How to Install and Manage Memcache on Linux

Required installation packages:

1.      memcache package: memcached-1.4.0.tar.gz
2.      PHP extension package: memcache-2.2.5.tgz
 
Install memcache into the /usr/local/lib directory:
# Versions may differ; choose the version that matches yours  
sudo  tar zxvf memcached-1.4.0.tar.gz   
cd memcached-1.4.0  
sudo  ./configure –prefix=/usr/local/web/lib/memcache  –with-libevent   
sudo  make  
sudo  make install  
Managing memcache:
# Start memcache  
cd  /usr/local/web/lib/memcache/bin/  
./memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211 -c 128 -P /usr/local/web/lib/memcache/memcached.pid  
  
# Check memcache status  
ps  -ef  |  grep  memcached  
   
# Stop the memcache process  
sudo  kill   21039   
Extension package installation
# Based on your own PHP installation directory  
sudo  tar xzvf memcache-2.2.5.tgz  
cd memcache-2.2.5   
sudo  /usr/local/web/php.5.3.3/bin/phpize   
sudo ./configure –enable-memcache –with-php-config=/usr/local/web/php.5.3.3/bin/php-config  –with-zlib-dir   
sudo  make  
sudo  make install  
Modify the php.ini file
sudo  vim /usr/local/web/php.5.3.3/lib/php.ini   
# Add: extension=memcache.so  

sudo  kill  -USR2 `cat /usr/local/web/ php.5.3.3/var/run/php-fpm.pid` #Restart

Leave a Comment

Your email address will not be published.