Categories: Ubuntu

Install Memcached on Ubuntu 20.04

In this guide, you’ll see how to set up and configure Memcached on your Ubuntu 20.04 system. For those unfamiliar with Memcached, it’s a free and open-source program that eases the re-extraction of information from a database with an object caching program, which allows for PHP based apps such as WordPress and Joomla to run smoothly without much latency. It does so by reducing the database load; the number of times a data source needs to be re-read upon loading an application.

Setting up Memcached on your system shouldn’t take very long if you properly follow the instructions below:

Installing
Sponsored
Memcached

The simplest and straightforward process for installing Memcached on Ubuntu is to unpack the package included with Ubuntu’s default software repository.

Fire up the terminal and enter the following command to run an update on the repository:

$ sudo apt update

The CLI toolkit is quite handy, and you should install it too. Although installing Memcached with the supporting toolkit is optional, it comes highly recommended.

Run the following command to install Memcached with supporting utilities.

$ sudo apt install memcached libmemcached-tools

With the above commands executed you should have the Memcached server should be ready to go.

Run a status check by typing in the following command:

$ sudo systemctl status Memcached

The status check should reveal if the installation went smoothly.

With all of the above covered, we’re ready to start configuring the server.

Configuring Memcached

To configure Memcached, we will need to edit the configuration file. Go to /etc/memcached.conf and start editing the file. While the default settings allow for smooth operations, you can always change the options to better match your hardware settings to speed up the cached memory accessibility by a notch more.

Sponsored

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:

$ sudo nano /etc/memcached.conf

Set the IP address which you want Memcached to listen to in the line above and change the default ports to ports of your choice.

To make the changes persistent, save, and exit the file. Then stop the Memcached server by typing in:

$ sudo systemctl stop memcached.service

Then you can restart it with:

$ sudo systemctl start memcached.service

Finally, enable the Memcached service with:

$ sudo systemctl enable memcached.service

You’ll see that changes you made before saving the file have been applied.

Allow via ufw firewall with the following command.

$ sudo ufw allow from 127.0.0.1 to any port 11211

Wrapping up

Despite being such a dynamic utility, setting up Memcached on ubuntu 20.04 is pretty simple. And it is just as easy to use and integrate into your system, provided that you keep an eye out for changes and update it regularly.

Ubuntu Server Admin

Recent Posts

Welcome to the Ubuntu Weekly Newsletter 883

Welcome to the Ubuntu Weekly Newsletter, Issue 883 for the week of March 9 –…

1 day ago

How to Install nvidia-smi on Ubuntu or Debian Linux

In this article, we will see how to install nvidia-smi on Ubuntu or Debian Linux.…

2 days ago

How to Install clang tool on Ubuntu or Debian Linux

In this article, we will see how to install clang tool on Ubuntu or Debian…

3 days ago

How to resolve Ubuntu 20.04 Container Signature Errors on Raspberry Pi ARM Devices

When working with Docker containers on Raspberry Pi devices, you might encounter frustrating signature verification…

3 days ago

How to fix DNS Resolution Issues with OpenVPN on Ubuntu 18.04

You’ve recently upgraded to Ubuntu 18.04 and found that your OpenVPN connection no longer resolves…

3 days ago

How to Fix Ubuntu 18.04 System Monitor Launch Issues

Have you ever tried to open System Monitor on your Ubuntu 18.04 system only to…

4 days ago