(dv):Install memcached
- This page was last modified on December 21, 2011, at 15:19.
From (mt) Community Wiki
Contents |
Overview
Memcached is a general-purpose distributed memory caching system. It is often used to speed up dynamic database-driven websites by caching data and objects in RAM to reduce the number of times an external data source (such as a database or API) must be read. Memcached runs on Unix, Windows and MacOS.
Results
This article will show you how to install memcached on a (dv) Dedicated-Virtual 3.5 or 4.0 Server.
Requirements
- You must have the Developer Tools installed.
- You must have SSH access set up for root or a sudo user.
Instructions
The latest version of memcached requires newer versions of Perl modules than are available in the CentOS repository. To fix this, we'll need to update these modules:
rpm --nodeps -e perl-IO-Socket-SSL-1.01-1.fc6 rpm --nodeps -e perl-Net-SSLeay-1.30-4.fc6 wget http://packages.sw.be/perl-Net-SSLeay/perl-Net-SSLeay-1.36-1.el5.rfx.i386.rpm wget http://packages.sw.be/perl-IO-Socket-SSL/perl-IO-Socket-SSL-1.34-1.el5.rfx.noarch.rpm rpm -i perl-Net-SSLeay-1.36-1.el5.rfx.i386.rpm rpm -i perl-IO-Socket-SSL-1.34-1.el5.rfx.noarch.rpm
Grab the files and install using yum:
wget -q -O - http://www.atomicorp.com/installers/atomic | sh yum install memcached
- Start memcached:
memcached -d -m 512 -l 127.0.0.1 -p 11211 -u nobody
The "-m SIZE" is the flag for setting the memory requirements in MBs. Once this cache is filled, memcache will just start to overwrite with newer content. Please experiment with this setting to find what works best for you.
- Move into your root folder
cd /root
- Grab the PECL memcache PHP extension:
wget http://pecl.php.net/get/memcache-3.0.6.tgz
- Untar the file:
tar -xvf memcache-3.0.6.tgz
- Open the directory:
cd memcache-3.0.6
- Install the PECL memcache PHP extension:
phpize && ./configure --enable-memcache && make
The PHP module path is different on a (dv) 4.0 than 3.5. Please use only ONE of the below commands.
- Copy the extension - (dv) 3.5:
cp /root/memcache-3.0.6/modules/memcache.so /usr/lib/php/modules/
- Copy the extension - (dv) 4.0:
cp /root/memcache-3.0.6/modules/memcache.so /usr/lib64/php/modules/
- Edit your php.ini:
vi /etc/php.ini
For more information on editing your php.ini file, please read: (dv):Edit php.ini.
- Add extension=memcache.so:
extension=memcache.so
- Restart Apache:
/etc/init.d/httpd restart
- If you check your server using a phpinfo page, you should now see a MemCache section on the page. You can now fully use the MemCache functionality in your PHP.
- If you are using Wordpress, install the Memcached Object Cache plugin for Wordpress to take full advantage of Memcached in your Wordpress environment (works with single-site, multi-site, and multi-database installations)
Notes/Supplemental Resources:
- (mt) User Forum Thread regarding memcached
- HowToForge: Installing The PHP-MemCache Module On CentOS 5.0
- Takizo: PECL Manual Install on Linux Centos