How to Install Memcached on Ubuntu 22.04
In this guide, two different methods of the installation of Memcached have been discussed in detail, along with its basic configuration on Ubuntu.
How to install Memcached on Ubuntu 22.04
There are two different methods for the installation of Memcached on Ubuntu either from its default repository by using the apt package manager or by downloading its tar package from its official website.
Method 1: How to install Memcached on Ubuntu 22.04 from its default repository
The first and simple method to install Memcached on Ubuntu is by installing it from its default repository, for which we will use the apt package manager:
To confirm the successful execution of the above command, we will find out the installed version details of Memcached by using the command:
Using the systemctl command, we will check the status of memcached:
To uninstall the memcached from Ubuntu with all its configuration files, we will use the purge command with apt package manager:
Method 2: Installing Memcached on Ubuntu 22.04 by downloading its tar package
Another method to install the the Memcached on Ubuntu is by downloading its zipped package from its official website using the wget command:
Unzip the zipped file to access its contents by using the command:
List down the contents of the directory to confirm the file has been unzipped:
Navigate to the memcached-1.6.15 directory using the cd command:
Now install the libevent-dev package because it is the dependency of memcached:
Now we will configure, compile all the files using the make command and then install all the compiled files:
How to configure the Memcached on Ubuntu 22.04
For configuration, we will open its config file using any text editor:
Now change the IP address in the configuration file with your IP address, for example, our IP address is 10.0.2.15:
Stop the Memcached service by using the systemctl command:
Now again start the service:
Also enable the service of the Memcached on your system:
And allow the traffic on your IP address at port 11211 using the ufw command:
How Memcached as caching database
There are multiple methods to connect with Memcached.
If your application is PHP based such as WordPress, Joomla, or Drupal and you want to connect Memcached as caching database then install php-memcached through the command:
For Python based applications:
Memcached is an open-source application that is used to run php-based dynamic web applications by reducing the load on their databases so that it can speed the performance of those applications. In this write-up, we have explored two installation methods of Memcached on Ubuntu one by using the default repository and the other by downloading its zipped package from its website.