Wondering how to install Memcached on Debian 11? We can help you.
With Memcached, we can speed up dynamic web applications by alleviating database load.
As part of our Server Management Services, we assist our customers with several Memcached queries.
Here, our support techs discuss how we can install Memcached on Debian 11 / Debian 10.
Install Memcached on Debian
We can get the Memcached package from the Debian OS repository. So, we do not need to set up external repositories.
Moving ahead, let us how our Support Techs get the installation done.
Initially, we update the repository index:
sudo apt update
Then, we install the Memcached using:
sudo apt install -y memcached
Once done, the service will be up and running automatically.
To verify the status of the service, we can use the ps or systemctl command:
sudo systemctl status memcached
Or
ps -ef | grep -wi memcached
Our output will be similar to this:
memcache 11047 1 0 03:40 ? 00:00:00 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1 -P /var/run/memcached/memcached.pid
-
Configure Memcached
With the help of its configuration file, /etc/memcached.conf we can manage the Memcached service.
Basically, there are four configurations by which we can bring up the production-ready Memcached instance.
a) The -m <num> sets the maximum memory we can use for object storage.
The default memory size is 64 MB. However, our Support Techs recommend a 256 MB cache.
-m 256
b) The -p <port_number> sets the listening port. The default port is 11211.
-p 11211
c) The -u <user_name> sets the Memcached service to run as a specific user.
-u memcache
d) The -l <ipaddress> sets the listening address.
By default, it listens on localhost only. So,to allow remote connections we need to change it to a network interface IP.
In addition, we can specify multiple addresses separated by comma or by using -l multiple times.
However, there are security risks when we configure Memcached to listen on the IP address.
This is because it allows anyone to access and may lead to a DDoS attack.
So, we need UFW (Firewall) to allow connections only from the trusted sources.
Eventually, we restart the Memcached process:
sudo systemctl restart memcached
-
Set up Firewall For Memcached
To secure the Memcached service, we need to configure the firewall to allow incoming connections from a trusted network to the Memcached port.
Here, this rule will allow connections from the xxx.xxx.x.x/xx subnet:
sudo ufw allow from xxx.xxx.x.x/xx to any port 11211
sudo ufw reload
-
Use Memcached
We have many Memcached clients available for programming languages like PHP, Python, Java, etc.
However, to use Memcached as a caching system for PHP applications such as WordPress, or Joomla, we need to install the Memcached to extension for PHP:
sudo apt install -y php-memcached
Once done, we restart the webserver to take the effect of the new extension.
[Need a hand? We are available 24*7]
Conclusion
In short, we learned how our Support Techs install Memcached on Debian 11 / Debian 10.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
0 Comments