In this article, we will have explained the necessary steps to install Memcached on Debian 11. Before continuing with this tutorial, make sure you are logged in as a user with sudo
privileges. All the commands in this tutorial should be run as a non-root user.
Memcached is an open-source and distributed memory object caching system that holds the most frequently queried data in memory. It is often used to speed up dynamic database-driven websites by caching data and objects in RAM to reduce the number of times an external data source must be read. It is also simple, easy to deploy, and can be integrated with several programming languages including PHP, Python, and more.
Prerequisite:
- Operating System with Debian 11
- Server IPv4 Address with Superuser Privileges (Root Access)
- Gnome Terminal for Linux Desktop
- PuTTy SSH client for Windows or macOS
- Powershell for Windows 10/11
- Familiar with APT Commands
Install Memcached on Debian 11
Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.
sudo apt update sudo apt upgrade
Step 2. Install Memcached on the Debian Bullseye system.
The Memcached package is available on Debian’s base repository and can be installed using the APT package manager. Install Memcached directly using the following command:
sudo apt install memcached libmemcached-tools
Once the Memcached is installed, start the Memcached service and enable it to start at system reboot:
sudo systemctl start memcached sudo systemctl enable memcached sudo systemctl status memcached
By default, Memcached listens on port 11211 and you can verify as below:
sudo netstat -pnltu
Result:
Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN 2390/memcached tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 443/sshd: /usr/sbin tcp6 0 0 :::22 :::* LISTEN 443/sshd: /usr/sbin
Step 3. Configure Memcached.
Now that the Memcached is installed, its configuration file can be found at /etc/memcached.conf
:
nano /etc/memcached.conf
Change some default options as per your requirements:
-l 127.0.0.1 -U 0 -p 11211 -u memcache -m 2000
Restart the Memcached service for the changes to take effect:
sudo systemctl restart memcached
Step 4. Enable Memcached for PHP and Python Applications.
Run the commands below to install the PHP Memcached PHP extension:
sudo apt install php-memcached
To use Memcached with Python, install the extension below:
pip install pymemcache pip install python-memcached
That’s all you need to do to install the Memcached on Debian (Bullseye). I hope you find this quick tip helpful. For further reading Memcached distributed memory object caching system on Debian’s system, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.