Memcached is a very popular, open source distributed memory caching system, that is used for temporarily storing information that is most likely to be used by a databse. It is primarily used to boost the speed of websites that uses heavy databases, but its use are not limited with database only, memcaahed can be used with other object types as well. Memcached does not write any data to disk & as it runs in the memory to run, it is very fast.
Memcacahed can be used with various web servers like apache, nginx etc, also many programming languages like PHP, Python, Ruby have memcached libraries. In this tutorial, we are going to learn to install memcached on RHEL & CentOS machines.

Also Read: How to install Varnish for Apache Web Server

Recommended Read: How to install REDIS in LInux


EPEL repository enabled for CentOS and RHEL systems

Memcached packages are not available in the default RHEL/CentOS repositories & we need to enable EPEL repository to install it. To enable the EPEL repository, run the below mentioned commands (corresponding to the operating system being used)


$ sudo dnf install


$ rpm -Uvh

RHEL/CentOS 6 (64 Bit)

$ rpm -Uvh

RHEL/CentOS 6 (32 Bit)

$ rpm -Uvh

Installation on CentOS/RHEL

Once the EPEL repository has been enabled, we can install memcached & its requred dependencies using yum,

$ yum install memcached php-memcached

That’s it, this will install memcached on the system. We now need to start its service & enable it for the boot time,

$ systemctl start memcached
$ systemctl enable memcached

Installation on Ubuntu

For Ubuntu machines, we need not add any extra repositories & can install memcached by running,

$ sudo apt-get install memcached php-memcached

Once the package has been installed we will restart the apache server (as memcached comes pre-configured) to implement the changes.



To see all the information regarding the memcached using the follwoing command,

$ memcached -h

If we need to change or modify the default settings for Memcached, we can do that using its configuration file.
The defaullt configuration for CentOS/RHEL, is at the location ‘/etc/sysconfig/memcached’ & for Ubuntu, configuration file is located at ‘/etc/memcached.conf’. If changes are needed to be made to memcached, they are to be done in this file. Changes that can be made include port number (default 11211), Maximum connections , cache size etc.

After making changes to the file, be sure to restart the service to implement the changes. We now have memcached ready for use & if you guys need any more help or have any queries, be sure to reach out using comment box below.

If you think we have helped you or just want to support us, please consider these :-

Connect to us: Facebook | Twitter

Become a Supporter - Donate us some of you hard earned money: [paypal-donation]

Linux TechLab is thankful for your continued support.