Linux Commands and Scripts

Easy to Install Memcached on Ubuntu 20.04

In this article, we’ll explain how it is easy to install Memcached on Ubuntu 20.04.

Memcached is free and open-source, high-performance, distributed memory object caching system software. Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.

Prerequisites

Let’s get started with the installation.

1. Keep the server updated

# apt update -y

# apt upgrade -y

2. Install Memcached

Run the following command to install Memcached with supporting utilities.

# apt install memcached libmemcached-tools

3. Start and enable memcached.service

After the installation, start and enable the memcached.service, using following commands:

# systemctl start memcached

# systemctl enable memcached

Run a status check by typing in the following command:

# systemctl status Memcached

Configure Memcached

In case, you want to configure Memcached, you will need to edit the configuration file. Go to /etc/memcached.conf and start editing the file.

# vi /etc/memcached.conf

One setting that you can change is the default IP address 127.0.0.1, which Memcached listens on. You can specify IP address listening by editing the following line in the config file.

After making the changes restart memcached.service

# systemctl restart memcached

Configure firewall

In case, you are using firewall UFW, add port Memcached default port 11211 like shown below:

# ufw allow from 127.0.0.1 to any port 11211

That’s it. The installation has been completed.

Related Articles