Install Latest Memcached on CentOS 6.x/7.x

We start with installing Memcached via yum. Although the distros install Memcached 1.4.4, its easier to let yum configure startup scripts etc. and upgrade the binary later.

yum install memcached

Memcached requires libevent

mkdir /downloads
cd /downloads
tar -xvzf lib*
cd lib*
./configure --prefix=/usr
make install

Next, install Memcached. Note the prefix. By default it installs to /usr/local folder, by defining prefix option we overwrite the yum copy.

cd /downloads
tar -xvzf mem*
cd mem*
./configure --prefix=/usr
make install

Check your Memcached version

memcached -h

If you get this error;

error while loading shared libraries: cannot open shared object file: No such file or directory

you need to create a link

ln -s /usr/lib/ /usr/lib64/

Check memcached version, if it works you can enable it as a service.

chkconfig memcached on

Finally, to install the PHP module

pecl install memcache

If you want to configure/optimize Memcached

nano /etc/sysconfig/memcached
#Max memory for cache (MB)
# Use -k if you have lots of memory, it locks down all paged memory
# Set -t the number of CPUs
OPTIONS="-k -t 4 -c 1024 -l"



Leave a Reply

Your email address will not be published. Required fields are marked *