Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Install and Configure Memcached on Ubuntu - DesignLinux

May 29 2020
designlinux 0 Comments

Memcached is a free and opensource in-memory caching system that speeds up web applications by caching large volumes of data in memory that are generated from page load requests or API calls. Memcached is particularly useful in speeding up PHP-based web applications such as WordPress, Joomla, Drupal, and Python applications as well.

In this tutorial, we look at how you can install Memcached on Ubuntu. For demonstration purposes, we will use Ubuntu 20.04 Focal Fossa. Granted, the same guide will apply for Ubuntu 16.04 and later versions.

Prerequisites

As we move along, ensure you have the following in check:

  • An instance of Ubuntu 20.04 Server.
  • A regular user with Sudo privileges.

Let’s now roll our sleeves and dive in.

Installing Memcached in Ubuntu Server

Before installing Memcached, let’s first update the package list of the packages installed using apt command.

$ sudo apt update
Update Ubuntu 20.04 Server

Update Ubuntu 20.04 Server

This should take a minute or two depending on the speed of your internet connection. Once the update is complete, install Memcached by running the command below. This will install Memcached alongside other dependencies and packages.

$ sudo apt install memcached libmemcached-tools
Install Memcached in Ubuntu 20.04

Install Memcached in Ubuntu 20.04

When prompted, press ‘Y’ on the keyboard and hit ENTER to proceed with the installation.

Once installed, the Memcached service should start automatically. This can be verified by checking the status of Memcached as follows.

$ sudo systemctl status memcached
Check Memcached Status

Check Memcached Status

The output confirms that Memcached is up and running.

Configuring Memcached in Ubuntu

The default configuration file for Memcached is /etc/memcached.conf. It’s also important to mention that by default, Memcached listens on port 11211 and is configured to listen on the localhost system. You can confirm this by checking the configuration file on line 35 as shown.

$ sudo nano /etc/memcached.conf
Check Memcached Configuration

Check Memcached Configuration

If the application connecting to the Memcached service is sitting on the same server where Memcached is installed, then there’s no need to make changes to this line. However, if you have a remote client that you want to allow access to Memcached caching service, then you need to edit this line & add the remote client’s IP address.

Suppose, you have a remote client with IP 192.168.2.105 running an application that needs to connect to the Memcached service. To allow access, simply delete the localhost IP address (127.0.0.1) and replace it with the remote client’s IP address. The assumption here is that both systems are in the same Local area network.

-l 192.168.2.105
Configure Memcached Connection

Configure Memcached Connection

Save and exit the configuration file.

Next, restart the Memcached service to apply the changes.

$ sudo systemctl restart memcached

Lastly, to allow remote connections to the Memcached server, we need to open the Memcached default port – port 11211 – on the firewall.

To achieve this run the commands:

$ sudo ufw allow 11211/tcp

Then reload the firewall to apply the changes.

$ sudo ufw reload

To verify that the port is open, execute:

$ sudo ufw status
Open Memcached Port on UFW Firewall

Open Memcached Port on UFW Firewall

Enabling Memcached for Applications

Depending on the application you are running, you need to install a language-specific client to enable Memcached to serve the requests.

For PHP applications such as Joomla or WordPress, execute the command below to install the additional packages:

$ sudo apt install php-memcached
Install Memcached PHP Extension

Install Memcached PHP Extension

For Python applications, ensure that the following Python libraries are installed using the pip package manager.

$ pip install pymemcache
$ pip install python-memcached

And this wraps up our topic on how to install and configure Memcached on Ubuntu. Your feedback will be much appreciated.

Sharing is Caring…
Share on FacebookShare on TwitterShare on LinkedinShare on Reddit

Related

Tags: open source caching tools, Ubuntu Tips

How to Install WordPress with Apache in Ubuntu 20.04

Prev Post

How to Install LEMP Stack with PhpMyAdmin in Ubuntu 20.04

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 0
  • 493
  • 612,672

DesignLinux.com © All rights reserved

Go to mobile version