Help Docs Server Administration Linux Server Administration Installing Memcached on Ubuntu

Installing Memcached on Ubuntu

Install Memcached on Ubuntu 12.04+ to speed up dynamic sites by caching database content. Root access is required for setup.

These instructions are for Ubuntu versions 12.04 and up. They are intended specifically for installing Memcached on a single Ubuntu LTS node. You must be logged in as root to install Memcached.

Install Memcached

It is best practice before any installation, that you update your packages. You can do this by using the following command:

apt-get update

Now that your packages are updated, you can install Memcached:

apt-get install memcached

Configure the installation

View the information on the Memcached command:

memcached -h

The default configuration file will be found at /etc/memcached.conf

Memcached will start on port 11211 by default in the configuration file:

#Default connection port is 11211
-p1121

To change the port, use vim to change the number in the configuration file.

For example, if you want to run Memcached on port 1337 with 4GB of memory and allow a maximum of 2,000 connections, you would change the configuration file as shown below.

vim /etc/memcached.conf

Edit the following sections:

-p 1337
-m 4096
-c 2000

Save and exit the file and then restart Memcached.

service memcached restart

Start, Stop and Check Status

You can run the following commands to start, stop and check the status of Memcached

Start

service memcached start

Stop

service memcached stop

Check Status

service memcached status

Now that you’ve seen how to install Memcached, let’s take a look at how to install the PHP Extension in our article Installing Memcached PHP Extension on Ubuntu.

Was this article helpful?