Memcached is a program that is used to speed up the extraction of data from the database and other tasks by caching several objects. Caching data helps in running applications smoothly and without any latency.
Installation of Memcached
First, update the package repository for installing Memcached and other required tools.
$ sudo apt update
After updating the systems package repository, install the Memcached and command-line tools that help in managing the Memcached server.
$ sudo apt install memcached libmemcached-tools
Press “y” to continue.
After the completion of the installation, the server should start automatically.
To verify the Memcached server’s status, run the command
$ sudo systemctl status memcached
You can see that it is active.
So this is how simply you can install memcached on Ubuntu 20.04 LTS.
Let’s configure it now.
The default settings are fine for all basic operations but if you want to configure the Memcached then you need to edit the Memcached configuration file.
Otherwise, if you want to allow remote access then you need to configure the /etc/memcached.conf file
$ sudo nano /etc/memcached.conf
Since the default IP address of the Memcached server is 127.0.0.1 on which Memcached is listening, you need to change it to the server’s IP address. So in the line “-l 127.0.0.1”, change “127.0.0.1” with the IP address of the server. For example, 192.168.18.135
The default port number is 11211, you can change it as well if you want.
Once the server’s IP address is set. Save the file and exit.
Now, restart the Memcached service using the systemctl command to apply the recent changes.
$ sudo systemctl restart memcached
After restarting the Memcached service, allow the client’s IP address(i.e 192.168.18.120) and open port 11211 in the Firewall
$ sudo ufw allow from 192.168.18.120 to any port 11211
After configuring the firewall, you are ready to access it remotely through the allowed client’s machine.
This is how you can install and configure Memcached to your desired configuration settings.
TUTORIALS ON LINUX, PROGRAMMING & TECHNOLOGY