How to install Memcached on Ubuntu 20.04

2021-06-11 By John 1939 Views linux memcached
33 reviews

Memcached is an open-source, high-performance, distributed memory object caching system. Its simple design promotes quick deployment, ease of development, and solves many problems facing large data caches. Its API is available for most popular languages.


Memcached serves a large hash table distributed across multiple machines. It is used for speeding up dynamic web applications by reducing database load. Memcached reduces the load by storing data objects in dynamic memory. Memcached stores data based on key-values for small arbitrary strings or objects including:

  • API calls
  • Page rendering
  • Result of API calls


This tutorial provides step by step process of installation of Memcached in Ubuntu 20.04.


Installation of Memcached


  1. Run a repository update as a primary step prior to the installation.

    # apt update
    

    memcached1

  2. Now CLI toolkit of the Memcached is to be installed even though it is optional, it is highly recommended. Run the following command.

    # apt install memcached libmemcached-tools
    

    memcached2

  3. Once done, run the status check by running the following command.

    # systemctl status memcached
    

    memcached3


Configuration of Memcached


  1. Edit the configuration file /etc/memcached.conf. Open the file using nano editor and one setting that you can change is the default IP address 127.0.0.1, which Memcached listens on. You can specify the server IP address listening by editing the following line in the config file.

    memcached4

    Once the server IP has been entered, save the file and exit.

  2. To reflect the changes, disable and enable the Memcached daemon using the following commands.

    # systemctl stop Memcached
    
    # systemctl start Memcached
    
    # systemctl enable memcached
    

    memcached5

  3. Final step to allow port number 11211 through UFW for allowing Memcached port number.

    # ufw allow from 127.0.0.1 to any port 11211
    

    memcached6

    NOTE: Replace the IP address with the original IP address if you have changed the configuration file.

What do you think about this article?

Rate this article
LayerStack Promotion
Need assistance?

Try this guide to receive free bundled services at signup on a new free account.

Sign Up

Your Feedback Is Important

We hope you’ll give the new products and updates a try. If you have an idea for improving our products or want to vote on other user ideas so they get prioritized, please submit your feedback on our Community platform. And if you have any questions, please feel free to ask in the Community or contact our Technical Support team.