How to install and configure memcached on Ubuntu Linux 18.04/20.04

‮tth‬ps://www.lautturi.com
How to install and configure memcached on Ubuntu Linux 18.04/20.04

To install and configure memcached on Ubuntu Linux 18.04 or 20.04, follow these steps:

  1. Install the memcached package using the following command:
sudo apt-get update
sudo apt-get install memcached
  1. After the installation is complete, start the memcached service using the following command:
sudo systemctl start memcached
  1. To configure memcached, you will need to edit the /etc/memcached.conf file. This file contains a number of configuration options that you can use to fine-tune the behavior of memcached. Some of the options that you might want to consider adjusting include:
  • -m: This option specifies the amount of memory, in megabytes, that memcached is allowed to use.
  • -l: This option specifies the IP address and port that memcached will listen on.
  • -u: This option specifies the user that memcached should run as.

For example, to allow memcached to use 256MB of memory and listen on IP address 127.0.0.1 and port 11211, you can set the following options in the configuration file:

-m 256
-l 127.0.0.1
-p 11211
  1. Save the configuration file and restart the memcached service using the following command:
sudo systemctl restart memcached
  1. To verify that memcached is running, you can use the memcached-tool utility to check the status of the server:
memcached-tool 127.0.0.1:11211 stats

This command should display a list of statistics for the memcached server.

Created Time:2017-10-28 21:39:04  Author:lautturi