Install Memcached on Ubuntu for PHP

  • Avinash
  • 1
  • Aug 09, 2012
  • Tutorial

In this article we will see how we can Install MemcacheD for PHP on Ubuntu.

Memcached is very useful for increasing the site performance. There are several ways in which you can increase the site performance with MemcacheD, I have already written one of the way on this site which you can find at Save Session in Memcached.

Memcached is a standalone daemon which runs on your machine as service just like the apache.

So let’s start with installation of the memcached.

Install MemcacheD

At very first we need to install Memcached service on machine. All you need to do is execute below command. You will need root privileges for the same.

sudo apt-get install memcached
sudo apt-get install memcached

Install Memcached

By default Memcached service runs on 11211 port. You can change it to what ever you want.

Install PHP Extension for Memcached

So now memcached service is installed in your machine. Now if you want to make it run with the PHP then you need to Install PHP extension for Memcached.

All you need to do is perform below command in terminal.

sudo apt-get install php5-memcached
sudo apt-get install php5-memcached

Install Memcached Extension for PHP

By default Memcached service runs on 11211 port

Restart Apache/PHP

After installing the service it’s time to reload the configuration. We can perform the same by restarting the apache. You need to perform below command.

sudo service apache2 restart
sudo service apache2 restart

We can get this changes in effect by restarting php service also. You need to perform below command for the same.

sudo service php5-fpm restart
sudo service php5-fpm restart

Once you restart the apache or PHP all you need to check you php configuration using phpinfo();. You will see below block on your configuration page.

Check Memcached Support

Share if you have any comments on above process.

There are many things to get yet, so Follow us on Twitter, Like us on Facebook and Subscribe via Email to stay updated.

Related Posts

Written by Avinash

Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.

View all posts by: