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.
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 127.0.0.1:11211.
Even though Memcached is installed, we also need to install the Memcached extension for you to successfully use it on your website.
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.
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.
Comments
Add comment