How to Configure Memcached For PHP on Ubuntu

Have you installed memcached on your Ubuntu and yet you're unable to see Memcache section on your phpinfo page ? Or do you want to install , configure and run your PHP application with memcached ? Either one, you have visited the right place to seek configuration for memcached and PHP on your Ubuntu machine. I promise this tutorial is very simple, you don't need to modify any file on your Ubuntu. Here we go...

First, you need to make sure you have installed and run memcached correctly on your Ubuntu box. To check this, just run :
ps -ef | grep memcached

You should see something like this (it's not necessary exactly same, but you know what I mean) :
memcache 1826 1 0 Feb05 ? 00:00:00 /usr/bin/memcached -m 64 -p 11211 -u memcache -l
kevin 13616 9479 0 14:27 pts/3 00:00:00 grep memcached

If you saw both of them on your terminal, then you can execute the following command now :
sudo apt-get install php5-memcache

Otherwise, you need to run this command first, before running command above :
sudo apt-get install memcached

All done ? Not yet, you still have to restart your Apache web server to apply this changes. I assumed you already know how to restart it, but in case you don't :
sudo /etc/init.d/apache2 restart
Now you're done, you can check if memcached is configured properly for your PHP by creating PHP file on your root document and type this into that file then save it :
echo phpinfo();

Open that file through http://localhost -- I assumed you place that code in index.php file. You will see Memcache section like this one :
Memcached for PHP on Ubuntu