# How to install Memcached on Debian 10?

{% embed url="<https://youtu.be/5uyJzH4bzy4>" %}

### **Overview**

Memcached is a free and open-source application. It is used to speed up dynamic web applications by reducing the database load.&#x20;

This tutorial demonstrates how to set up Memcached on Debian 10.

### **Prerequisites**

There are certain prerequisites that need to be met before you begin. &#x20;

* A server running Ubuntu 22.04
* Non-root sudo user privileges

### **Get Started**

**Step 1 - Memcached installation for Debian 10**

* The Ubuntu 20.04 repositories contain the memcached package. Enter the following command as root or user with sudo access to install it:

```
sudo apt update
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1291_image-2023-4-13_15-3-41.png" alt="" height="231" width="1500">

```
sudo apt install memcached libmemcached-tools
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1292_image-2023-4-13_15-4-56.png" alt="" height="104" width="1500">

The libmemcached-tools package contains many command-line tools for communicating with the Memcached server.

* The Memcached service will launch automatically after the installation is finished. You can confirm it by examining the service's state:

```
sudo systemctl status memcached
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1293_image-2023-4-13_15-6-51.png" alt="" height="171" width="1500">

Congratulations! Memcached is successfully installed on your Debian 10 server.

**Step 2 - Setting up Memcached**&#x20;

* The /etc/memcached.conf file allows for the configuration of Memcached options. For the majority of users, the default configuration options are adequate.

**Step 3 - Remote Access**

* Memcached can be used to launch a distributed denial-of-service (DDoS) attack if it is improperly configured. You must set up your firewall such that only trustworthy clients are permitted access to the Memcached UDP port 11211 in order to allow remote connections to the Memcached server.
* It is assumed in the example below that you are connected via a private network to the Memcached server.
* Edit the memcached configuration first, then configure the service to listen on the server's private networking interface. This can be done by opening the memcached.conf settings file:

```
sudo nano /etc/memcached.conf
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1294_image-2023-4-13_15-10-34.png" alt="" height="34" width="1500">

* Find the line that starts with -l 127.0.0.1, and substitute 192.168.100.20 for 127.0.0.1 in that line.

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1295_image-2023-4-19_16-45-15.png" alt="" height="535" width="1200">

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1296_image-2023-4-19_16-48-54.png" alt="" height="531" width="1200">

* To make the modifications effective, restart the Memcached service:

```
sudo systemctl restart memcached
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1297_image-2023-4-13_15-12-9.png" alt="" height="33" width="1500">

* The memcached port must be opened in the firewall after the service has been configured.

```
sudo ufw allow from 192.168.100.30 to any port 11211
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1298_image-2023-4-19_17-30-8.png" alt="" height="39" width="1500">

You can now establish a connection to the Memcached server from a remote location.

**Step 4 - Getting Connected to Memcached**

Memcached clients are available in a variety of versions and in numerous programming languages.

* For working with memcache, there are numerous Python libraries. With pip, you can install the library of your choice:

```
pip install pymemcache
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1299_image-2023-4-13_15-14-43.png" alt="" height="51" width="1500">

```
pip install python-memcached
```

<img src="https://customer.acecloudhosting.com/index.php?rp=/images/kb/1300_image-2023-4-13_15-16-0.png" alt="" height="64" width="1500">

### **Conclusion**&#x20;

We have successfully demonstrated how to set up Memcached on Debian 10.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.acecloud.ai/knowledge-base/tutorials/how-to-install-memcached-on-debian-10.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
