How to Install Memcached on Ubuntu 14.04 LTS
Memcached is a distributed, high-performance, in-memory caching system that is primarily used to speed up sites that make heavy use of databases. It can however be used to store objects of any kind. Nearly every popular CMS has a plugin or module to take advantage of memcached, and many programming languages have a memcached library, including PHP, Perl, Ruby, and Python. Memcached runs in memory and is thus quite speedy, since it does not need to write data to disk.
Pre-Flight Check
- These instructions are intended specifically for installing Memcached on a single Ubuntu 14.04 LTS node.
- I’ll be working from a Liquid Web Core Managed Ubuntu 14.04 LTS server, and I’ll be logged in as root.
Step #1: Install Memcached
As a matter of best practice we’ll update our packages:
apt-get update
Then installing Memcached and related packages is now as simple as running just one command::
apt-get install memcached
Step #2: Configuration of the Memcached Installation
Use the following command to view information on the memcached command:
memcached -h
The default configuration file can be found at:
/etc/memcached.conf
When started, Memcached will start on port 11211 by default per the default configuration file:
# Default connection port is 11211
-p 11211
To change the port, simply change the number in the configuration file.
For a refresher on editing files with vim see: New User Tutorial: Overview of the Vim Text Editor
EXAMPLE: If I wanted to run Memcached on port 1337, with 4GB of memory, and allow a maximum of 2,000 connections, I would change the config file as follows.
Let’s edit the configuration file:
vim /etc/memcached.conf
To the following:
-p 1337
-m 4096
-c 2000
Exit and save the configuration file, and then restart Memcached
service memcached restart
Related Articles:

About the Author: J. Mays
As a previous contributor, JMays shares his insight with our Knowledge Base center. In our Knowledge Base, you'll be able to find how-to articles on Ubuntu, CentOS, Fedora and much more!
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.
Latest Articles
2024 cPanel and Plesk pricing breakdown
Read ArticleCentOS Linux 7 EOL — everything you need to know
Read ArticleHow to install Node.js on Linux (AlmaLinux)
Read ArticleUpgrading or installing PHP on Ubuntu — PHP 7.2 and Ubuntu 22.04
Read ArticleWhy is your IP blocked?
Read Article