How to Easily Install and Configure Memcached on Ubuntu Server

Learn to boost your web application's speed with our straightforward guide on installing and configuring Memcached on Ubuntu server. From simple installation steps to optimizing memory usage, we make it easy for beginners to enhance their server's performance. Follow our expert tips to ensure your Memcached setup is efficient and tailored to your needs.
Software Logos
Install and Configure Memcached on Ubuntu Server

Memcached is a high-performance, distributed memory caching system designed to speed up dynamic web applications by alleviating database load. This guide will walk you through the steps to install and configure Memcached on an Ubuntu server, ensuring even beginners can follow along.

What You’ll Need

  • A server running Ubuntu
  • Command line/SSH access to the server
  • Basic understanding of Linux commands

Installing Memcached on Ubuntu

Step 1: Update Your Ubuntu Server

Always start by updating your system’s package list to ensure you get the latest versions of the software.

sudo apt update && sudo apt upgrade -y

Step 2: Install Memcached

With your system updated, install Memcached and its PHP extension with the following command:

sudo apt install memcached libmemcached-tools php-memcached -y

Step 3: Verify the Installation

Ensure Memcached is installed correctly by checking its status.

sudo systemctl status memcached

Configuring Memcached on Your Ubuntu Server

Adjusting Memory Usage

One of the key configurations for Memcached is limiting its memory usage, crucial for optimizing server performance.

Step 1: Edit the Memcached Configuration File

Open the configuration file in your preferred text editor.

sudo nano /etc/memcached.conf

Step 2: Limit the Memory Usage

Find the line -m 512. This line specifies Memcached is allocated 512MB of memory. Adjust this value based on your server’s available memory and needs.

Step 3: Restart Memcached

For the changes to take effect, restart Memcached.

sudo systemctl restart memcached

Enabling and Starting Memcached Service

Step 1: Enable Memcached to Start at Boot

sudo systemctl enable memcached

Step 2: Start the Memcached Service

sudo systemctl start memcached

Verifying Memcached Operation

Checking Memcached Stats

You can check Memcached’s operation and performance using memcached-tool.

memcached-tool stats


This guide has walked you through the simple steps of installing and configuring Memcached on an Ubuntu server. By following these steps, you can improve the performance of your web applications significantly.

Wan si System Administrator

Elena Petrova

I'm Elena Petrova, originating from Eastern Europe. My expertise lies in database management, efficient backups, and server administration. I'm committed to safeguarding critical data and simplifying tech topics through my writing.


We take pride in offering independent and unbiased reviews of professional web hosting, dedicated servers, backup, and security services. Our commitment to integrity ensures that our evaluation standards apply consistently to all companies we review. While we may receive monetary compensation from some of the companies featured on our site, it’s important to note that such compensation does not in any way influence the direction or conclusions of our reviews, nor does it impact our rankings.

Our content is designed for informational purposes, and we emphasise that it should not be considered as professional advice. For specific needs, we recommend consulting with specialists who can provide tailored guidance. If you choose to use our referral services, you are consenting to third-party being contacted by the third-party company. It is essential to understand that we bear no responsibility for the actions or services of these third parties, and any disputes or issues arising from such interactions should be addressed directly with them.

You May Also Like

Best Practices for Securing Ubuntu Server: Comprehensive Guide

Securing an Ubuntu Server is essential to protect it against a multitude of threats that can compromise data, disrupt services, and exploit system resources. This comprehensive guide outlines a series of best practices aimed at fortifying Ubuntu servers, making them...

Pin It on Pinterest

Share This