How to Install Memcached on Ubuntu 14.04.

Memcached Memcache Cache Ubuntu Python PHP


Memcached is a high-performance, distributed memory object caching system, it is designed to speed up dynamic web applications by alleviating backend database load.

In this tutorial, we will be installing Memcached, and optionally PHP Memcached extension and Python Memcached module if you are using Memcached for Python or PHP.

Installing Memcached.

First, let's make sure our apt package database is up to date. This way you will always get the latest version of the package you are installing. Execute the following commands to update apt-get and install Memcached.

# sudo apt-get update
# sudo apt-get install memcached

Memcached is now installed and is ready to be used and by default Memcached will be running on

Even though Memcached is installed, we also need to install the Memcached extension for you to successfully use it on your website.

Installing Memcached extension for PHP (optional).

Luckily, apt-get comes with the php5-memcached package. You can install Memcached extension by typing:

Note, there are two Memcached extensions for PHP, php5-memcache and php5-memcached. Either one will work for most cases, however, we will be using php5-memcached in this tutorial as it is stable.

# sudo apt-get php5-memcached
# sudo service apache2 restart

Now you should be able to use Memcached in your PHP website.

Installing Memcached module for Python (optional).

Python Memcached module is available on pip and apt-get. If you have pip installed, it is recommended to use pip.

To install python Memcached module using pip, use the following command:

# pip install python-memcached

To install python Memcached module using apt-get, use the following command:

# apt-get install python-memcache

Now you should be able to use Memcached with your python application.

    No comments found for this tutorial, be the first to leave a comment!

Tutorial by

Last updated on
May 12, 2015