Home How To How To Install Memcached on Ubuntu

How To Install Memcached on Ubuntu [2021 Tutorial]

  • Memcached is an open-source cache manipulation tool mostly preferred to speed-up the database-driven websites.
  • Readers can Install Memcached on Ubuntu devices by performing a simple procedure.
  • They can also learn to configure and use it without becoming a victim of DDoS strikes.

Memcached on Ubuntu

The load time of WordPress, Drupal, and Jumla web applications is quite difficult to handle without a cache manipulation tool. That’s why developers prefer tools like Redis and Memcached to decrease the load time by increasing the interaction of databases with their websites.

How Do I Install Memcached on Ubuntu?

Page Contents


A user is required to go under certain procedures to install and use Memcached on Ubuntu properly. Because after installing it, he also needs to configure it and block the risks followed like DDoS. So I will now describe the proper procedure to complete this task.

Install Memcached on Ubuntu

Gladly, Memcached resides inside the Ubuntu repository store. So you don’t need to perform any extra methods for completing the manual installation. You just need to execute simple commands for the complete installation of the Memcached package.

sudo apt update
sudo apt install memcached libmemcached-tools

To check the status of the Memcached server:

sudo systemctl status memcached

If the installation goes well, you will see a result similar to the one provided below:

● memcached.service - memcached daemon
   Loaded: loaded (/lib/systemd/system/memcached.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2019-06-06 10:36:25 CDT; 27s ago
     Docs: man:memcached(1)
 Main PID: 19852 (memcached)
    Tasks: 10 (limit: 4682)
   CGroup: /system.slice/memcached.service
           └─19852 /usr/bin/memcached -m 64 -p 11211 -u memcache -l -P /var/run/memcached/memcached.pid

Oct 25 10:36:25 ubuntu1804 systemd[1]: Started memcached daemon.

To manipulate Memcached server depending upon your requirements:

sudo systemctl stop memcached.service
sudo systemctl start memcached.service
sudo systemctl enable memcached.service

Configure Memcached on Ubuntu

The configuration process of Memcached can be understood easily. Most of the time, you are only required to change the IP address to connect it with your server. The configuration file can be found at /etc/memcached.conf.

To start the configuration process:

sudo nano /etc/memcached.conf

To change port number or IP address:

# Default connection port is 11211
-p 11211

# Run the daemon as root. The start-memcached will default to running as root if no
# -u command is present in this config file
-u memcache
# Specify which IP address to listen on. The default is to listen on all IP addresses
# This parameter is one of the only security measures that memcached has, so make sure
# it's listening on a firewalled interface.

Save the implied changes and restart Memcached packages.

Secure Memcached on Ubuntu

Always ensure that Memcached is secure and remote access is allowed to trusted users. Because it can lead to DDoS strikes and may become a source for cybercriminals to enter your website’s database. For that, you need to configure Memcached correctly.

Users can enter specific IP addresses and Port numbers that are allowed to access remotely. Else, all the other clients or IP addresses will be blocked by the Ubuntu firewall.

For example:

sudo ufw allow from to any port 11211

If you are using Memcached as a caching database client for PHP platforms like WordPress or Drupal, you will be required to install the PHP-supported Memcached plugin.

sudo apt install php-memcached

In case you are using Memcached with Python, you need to consider a different scenario:

pip install pymemcache
pip install python-memcached

After installing the perspective extensions and performing the righteous configuration settings, Memcached will be protected and ready to use.

That’s all, thanks for your time spent reading How To Install Memcached on Ubuntu at it’sDailyTech.

A How-To expert, who's keen to help those who are unable to make the most out of their electronic devices. Especially the ones who don't want everything to be served on a plate.


Please enter your comment!
Please enter your name here