How to Install Memcached on Debian 11 / Debian 10

Memcached, the high-performance, distributed memory object caching system, is extremely useful in speeding up dynamic web applications by alleviating database load.

Memcached helps in minimizing the number of calls to database systems by caching data in memory. As a result, the subsequent requests for the same data can be served faster and thus improve web server performance.

Here, we will see how to install Memcached on Debian 11 / Debian 10.

Install Memcached on Debian

The Memcached package is available in the Debian OS repository. So, you do not need to set up external repositories to get the Memcached package.

First, update the repository index.

sudo apt update

Then, install the Memcached using the below command.

sudo apt install -y memcached

Once the installation is completed, the Memcached service will be up and running automatically. You can use the ps command or systemctl command to verify the status of the service.

sudo systemctl status memcached


ps -ef | grep -wi memcached


memcache 11047 1 0 03:40 ? 00:00:00 /usr/bin/memcached -m 64 -p 11211 -u memcache -l -P /var/run/memcached/

Configure Memcached

You can manage the Memcached service with the help of its configuration file /etc/memcached.conf. There are four important configurations by which you can bring up the production-ready Memcached instance.

The -m sets the maximum memory you can use for object storage. The default memory size is 64 MB. However, setting a 256 MB cache will be recommended.

-m 256

The -p sets the listening port for Memcached. The default port is 11211.

-p 11211

The -u sets the Memcached service to run as a specific user.

-u memcache

The -l sets the listening address for Memcached. By default, the Memcached listens on localhost only. So, you may need to change it to a network interface IP address to allow remote connections.

You can also specify multiple addresses separated by comma or by using -l multiple times. Here, I will configure Memcached to listen on


Configuring the Memcached to listen on the IP address comes with security RISK because it allows anyone to access and may lead to a DDoS attack. So, you must configure UFW (Firewall) to allow connections only from the trusted sources.
Restart the Memcached process.

sudo systemctl restart memcached

Set up Firewall For Memcached

As I said earlier, to secure the Memcached service, you will need to configure the firewall to allow incoming connections from a trusted network to the Memcached port.

The below rule will allow connections from the subnet (IP address ranging from to

sudo ufw allow from to any port 11211 sudo ufw reload

Use Memcached

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

sudo apt install -y php-memcached

Once you installed the PHP extension, restart your webserver to take the effect of the new extension.

Sumber: disini

Wagiman Wiryosukiro

Petani Sistem Informasi, tukang las plugin & themes Wordpress. Co-Founder Saat ini aktif sebagai Developer & kontributor di OpenMandriva Linux.

You may also like...

%d bloggers like this: