This article will help you to install Memcached with PHP Memcache PECL extension on Ubuntu 20.04 systems.


You must have shell access to your Ubuntu 20.04 system with sudo privileged account. Login to your system and complete this tutorial.

Step 1 – Installing Memcached on Ubuntu

First of all, update Apt package cache on your system then install Memcached service on your system. Execute below commands from command prompt.

Step 2 – Configure Memcached

You can find the details information about Memcache configuration here. For initial level configuration check for the following settings under Memcache configuration file /etc/memcached.conf.

-d => Run Memcached in deamon mode. You can use this option to configure your Memcached server to run as service. -m => Define the maximum number of Memory can be used by Memcached deamon. (default: 64 MB) -p => Defind port for Memcached to listen on. (default: 11211) -l => Define the IP address to Memcached listen on. Set to listen on all IPs(enterfaces) configured on system.

After making changes, restart the Memcached service.

Step 3 – Verify Memcache Setup

Use the following command to check and verify that Memcached service is running properly on your system. This will show you the current statstics of your Memcached server. So the values may be differ that below results. Output:

Step 4 – Installing Memcache/Memcached PHP Module

Now install latest PHP from ppa:ondrej/php PPA on your Ubuntu system. If you have already installed PHP on your system, just skip PHP installation commands below. Now install PHP Memcached module on your system. The below command will also do the required configuration. After completing the installation, you must restart the Apache service. Check if Memcache php extension is enabled and working properly. Create a info.php file under the document root of your domain with following code: /var/www/html/info.php

Now access info.php on the web interface and search for Memcache, You will get the result like below. https://server-ip/info.php


In this tutorial, you have learned to install Memcached service along with PHP extension on your Ubuntu 20.04 system.

How To Install Memcached on Ubuntu 20 04   TecAdmin - 22