How to install the Memcached daemon

This article will show you how to install the Memcached system within your Virtual Private Server.

Please note: the following article was originally created for our current generation of Virtual Private Servers. As such, these instructions may not be relevant to our previous generation of Virtual Private Servers.

Important: you will need to enable admin access to your server to perform this action. As such, we only recommend that advanced users undertake this action.

Step 1 of 8

Start by logging in to your server via SSH.

Step 2 of 8

Next, you will need to switch to the root user.

Step 3 of 8

From there, you can install Memcached by entering one of the following commands:

For CentOS: yum -y install memcached
For Ubuntu: apt install Memcached

Step 4 of 8

Next, enter the following command so that Memcached will be activated when you turn your server on:

systemctl enabled Memcached

Step 5 of 8

If you want, you can change its configuration by opening the configuration file with your fpreferred text editor and entering the command vim /etc/sysconfig/Memcached (for CentOS) or vim /etc/memcached.conf (for Ubuntu). By default, you’ll receive the following values:

PORT=”11211″

USER=”memcached”

MAXCONN=”1024″

CACHESIZE=”64″

OPTIONS=””

From there, you can add -1 127.0.0.1 -U 0 to the OPTIONS value to bind Memcached to localhost (thereby protecting it from certain attacks) and changing the CACHESIZE amount to a different figure (depending on how much RAM is available within your server).

Step 6 of 8

Once you’re happy with your changes, save your file.

Step 7 of 8

From there, restart Memcached by entering the command:

systemctl restart Memcached

Step 8 of 8

Once you’ve done this, you’ll now need to configure your website to use Memcached.