Categories: Ubuntu

Install and Configure Memcached on Ubuntu 22.04|20.04|18.04

Memcached is an in-memory key-value store, often used as a cache. It is designed to speed up dynamic web applications by reducing the number of times an external data source (such as a database) must be read. It is often used to cache data such as database query results, API responses, or pre-computed data that is expensive to compute.

Memcached stores data in memory, which allows for very fast access times. When a web application needs to read data, it first checks if the data is available in Memcached. If it is, the data is returned from the cache. Which is much faster than reading the data from an external data source. If the data is not available in the cache. It is read from the external data source and then stored in the cache for future use.

Sponsored

Installing and configuring Memcached on Ubuntu 22.04 is a relatively simple process. In this article, you will learn how to install Memcached on Ubuntu system.

Install Memcached on Ubuntu by running the command:

sudo apt install -y memcached

Once the installation is complete, you can start the Memcached service by running the command:

sudo systemctl start memcached

To ensure that Memcached starts automatically at boot, run the command:

sudo systemctl enable memcached

To configure Memcached, you will need to edit the configuration file located at /etc/memcached.conf. You can do this by running the command:

sudo nano /etc/memcached.conf

In the configuration file, you can adjust settings such as the amount of memory allocated to Memcached, the number of connections allowed, and more. Be sure to save your changes and exit the editor.

After making any changes to the configuration file. You need to restart the Memcached service for the changes to take effect. You can do this by running the command:

Sponsored
sudo systemctl restart memcached

Configure Memcached Firewall

By default, Memcached listens on port 11211

To allow incoming connections on the Memcached port, run the command:

sudo ufw allow 11211/tcp

Run one of the below the commands to verify, Memcached port is added to the firewall.

sudo ss -tulpn
OR
sudo netstat -tulpn

This will show you a list of the current firewall rules. and should include the rule allowing incoming connections on port 11211.

That’s it! You can now use Memcached to cache data and speed up your application.

The post Install and Configure Memcached on Ubuntu 22.04|20.04|18.04 appeared first on Osgrove.

Ubuntu Server Admin

Recent Posts

IBM LinuxONE 5 and Ubuntu Server, a great combination from day one

Today, IBM announced the launch of their latest server: the new IBM LinuxONE Emperor 5.…

16 hours ago

Ubuntu Weekly Newsletter Issue 890

Welcome to the Ubuntu Weekly Newsletter, Issue 890 for the week of April 27 –…

1 day ago

Ubuntu IoT Day in Singapore – Unlock compliant and scalable innovation in edge AI

Singapore | May 27, 2025 | Full-day event How do you build robust, performant edge…

2 days ago

Kolla Ansible OpenStack Installation (Ubuntu 24.04)

Kolla Ansible provides production-ready containers (here, Docker) and deployment tools for operating OpenStack clouds. This…

5 days ago

Canonical announces first Ubuntu Desktop image for Qualcomm Dragonwing™ Platform with Ubuntu 24.04

This public beta enables the full Ubuntu Desktop experience on the Qualcomm Dragonwing™ QCS6490 and…

6 days ago

The long march towards delivering CRA compliance

Time is running out to be in full compliance with the EU Cyber Resilience Act,…

6 days ago