Install, Configure And Verify Memcached in Ubuntu

Memcached is a high performance distributed memory object caching system and nowadays it’s kind of essential for Virtual Private Server (VPS) or dedicated server. In this tutorial I will show you How to Install Memcached In Ubuntu.

Memcached is a free and Open source distributed memory object caching System. Memcached used to speed up dynamic database driven website by caching data and objects in RAM to reduce the number of times an external data source (such as a database or API) must be read. (Wikipedia). It reduces the request of MySQL query and improve loading speed of dynamic website which utilizes Database.

You know every millisecond counts in Website loading time and it impacts a lot in Website revenue, Visitor satisfaction and SEO. So it’s essential to have a memcached in your web-server to improve your website performance.

If you are using Shared hosting then there’s a very little chances to have Memcached Installed and configured for your website. You can contact your hosting provider for more info about their features and performance. And if you are using VPS then you have the chances to add one more improvement in speed optimization in your website by installing and configuring Memcached.

Here is the instruction of installing Memcached in Ubuntu 14.04 or later version. In next I will add more tutorial about Installing Memcached in various Linux distribution line CentOS, Red Hat etc.

How To Install Memcached In Ubuntu

In this tutorial I’ve used my Playground Server which is DigitalOcean’s $5 droplet with Ubuntu 14.04 LTS installed and Basic LAMP server setup with Apache2, PHP5 and MySQL installed. I assume you have LAMP stack installed and if you need instruction of Basic LAMP stack installation, Head over to our LAMP installation Tutorial in Ubuntu.

Once everything is in it’s place or you are already in production mode, Install Memcahed and memcached extention for PHP5 using the commands below:

sudo apt-get install memcached php5-memcached

Note That: There are two php extension available. one is memcache while another is memcached. We will install memcached extension which is stable, feature rich and faster than memcache.

Once installed reload Apache:

sudo /etc/init.d/apache2 reload

Now to check installation of memcached and php5-memcached extension, create a info.php file in your Virtualhost’s root directory with the following content:

<?php
phpinfo();
?>

Now browse info.php file in your Browser by visiting http://<span style="color: #ff0000;">your_server_ip</span>/info.php

In this page scroll down or search for Memcached header section to ensure memcached php5 extension install information.

Memcached Installation and Configuration settings

You can also check weather memcached is running or not using:

ps aux | grep memcached

If the command above return something like:

memcache 12240 0.0 0.1 325400 1072 ? Sl 08:02 0:00 /usr/bin/<span style="color: #800000;">memcached</span> -m 64 -p 11211 -u memcache -l 127.0.0.1
root 13930 0.0 0.0 14056 908 pts/2 S+ 10:28 0:00 grep --color=auto <span style="color: #800000;">memcached</span>

That’s means Memcached is Working.

That’s all! Memcached is installed and configured in your Ubuntu. If you have encountered an issue, Please let me know using the comments below.

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive website improvement tips and tutorials.

 

We'll periodically send useful information, tips & tutorials to improve your website performance, conversion optimization, SEO and design tweaks to make your website better.

Thank you for signing up!

Please check your email and click the link provided to confirm your subscription.

Powered by Rapidology
No Comments

Post a Comment