How to Install Memcached on Ubuntu 16.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 memcached extension for you to successfully use it in your website.

Installing Memcached extension for PHP (optional).

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

Note, there are two memcached extension 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
Jul 16, 2016