How To Install Memcached on Debian 11

Install Memcached on Debian 11

In this tutorial, we will show you how to install Memcached on Debian 11. For those of you who didn’t know, Memcached, the high-performance, distributed memory object caching system, is extremely useful in speeding up dynamic web applications by alleviating database load. This reduces the number of times an external data source must be read, which lowers overheads and speeds up response times. The memory caching software is a free, open-source project that anyone can use.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you through the step-by-step installation of Memcached on a Debian 11 (Bullseye).


  • A server running one of the following operating systems: Debian 11 (Bullseye).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Memcached on Debian 11 Bullseye

Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt commands in the terminal:

sudo apt update
sudo apt upgrade

Step 2. Installing Memcached on Debian 11.

By default, Memcached is available on base Debian 11 repositories. Now run the following command to install it:

sudo apt install memcached libmemcached-tools

After installation, the Memcached service will start automatically. You can verify it by checking the status of the service:

sudo systemctl status memcached

Step 3. Configure Memcached.

The Memcached configuration file is /etc/memcached.conf and we can modify the Memcached configuration by running:

sudo nano /etc/memcached.conf

In the file below, locate localhost IP replace it with your actual server IP:

# memcached default config file
# 2003 - Jay Bonci <>
# This configuration file is read by the start-memcached script provided as
# part of the Debian GNU/Linux distribution.

# Run memcached as a daemon. This command is implied, and is not needed for the
# daemon to run. See the README.Debian that comes with this package for more
# information.

# Log memcached's output to /var/log/memcached
logfile /var/log/memcached.log

# Be verbose
# -v

# Be even more verbose (print client commands as well)
# -vv

# Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
# Note that the daemon will grow to this size, but does not start out holding this much
# memory
-m 256

# Default connection port is 11211
-p 11211

# Run the daemon as root. The start-memcached will default to running as root if no
# -u command is present in this config file
-u memcache

# Specify which IP address to listen on. The default is to listen on all IP addresses
# This parameter is one of the only security measures that memcached has, so make sure
# it's listening on a firewalled interface.

# Limit the number of simultaneous incoming connections. The daemon default is 1024
# -c 1024

# Lock down all paged memory. Consult with the README and homepage before you do this
# -k

# Return error when memory is exhausted (rather than removing items)
# -M

# Maximize core file limit
# -r

# Use a pidfile
-P /var/run/memcached/

Save and close the file. Then restart the Memcached process to take effect:

sudo systemctl restart memcached

Step 4. Configure Firewall.

If you have UFW installed, you need to create UFW allow rules on port 11211:

sudo ufw allow proto tcp from <your ip address> to any port 11211
sudo ufw reload

Step 5. Use Memcached.

There are many Memcached clients are available for programming languages like PHP, Python, and many more. However, to use Memcached as a caching system for your PHP applications such as WordPress, you will need to install the Memcached to extension for PHP:

sudo apt install php-memcached

Congratulations! You have successfully installed Memcached. Thanks for using this tutorial for installing the latest version of Memcached on Debian 11 Bullseye. For additional help or useful information, we recommend you check the official Memcached website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button