How to Install Memcached on Ubuntu 16.04

r00t October 18, 2017

Install Memcached on Ubuntu 16.04

In this tutorial we’ll learn how to install Memcached on Ubuntu 16.04. We will also install and configure its prerequisites. Memcached is a distributed, high-performance, in-memory caching system that is largely used to speed up sites that make heavy use of databases. It can however be used to store items of any kind. Nearly every popular CMS has a plugin or module to make the most of memcached, and lots of programming languages have a memcached library, including PHP, Perl, Ruby, and Python. Memcached runs in memory and is thus quite speedy, as it doesn’t need to write data to disc.

I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 16.04 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install Memcached on Ubuntu 16.04

Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:

apt-get update -y
apt-get upgrade -y

Step 2. Installing Memcached.

Installing Memcached on Ubuntu is very straightforward, run the following commands:

apt-get install memcached php-memcached

After installing memcached then you can start/restart/stop memcached with the following commands:

systemctl restart httpd.service
systemctl start memcached.servive

Step 3. Configure Memcached.

Memcached must now be configured. We’ll edit its configuration file to make a few key optimizations:

nano /etc/memcached.conf

Change this value to one that makes sense to your situation. Particular switches of interest have been “-p” to change the memcached port, “-m” to allocate RAM into the cache, and “-c” to establish the maximum connections allowed to the cache daemon.

Once you’ve reconfigured memcached, also when the PHP module is installed, then you will need to restart memcached. You will also have to restart Apache so any hosted apps pick up the new module:

systemctl restart httpd.service
systemctl restart memcached.servive

Congratulation’s! You have successfully install and configure Memcached on your Ubuntu 16.04 server. Thanks for using this tutorial for installing Memcached on Ubuntu system.

The Tags:

Leave a Comment

Comments are closed.