This article will help you to install Memcached with PHP Memcache PECL extension on Ubuntu 14.10, 14.04 and 12.04 systems.
First of all it is recommended to update your system with latest packages.
sudo apt-get update
Now run following command to install memcached service on your system
sudo apt-get install memcached
Now we are going to install php with couple of more required packages for setup. We also need to install Memcache module for php using below commands.
sudo apt-get install php5 php5-dev php-pear php5-memcached sudo apt-get install libmemcached-dev build-essential
Now install Memcache php extension using PECL to complete setup.
sudo pecl install memcache
Now enable memcache support in php. Before proceeding with a new file just make sure there are no php memcache configuration file exist. If file already exists just skip following command:
echo "extension=memcache.so" > /etc/php5/apache2/conf.d/20-memcache.ini
Just restart your Apache service:
sudo service apache2 restart
Use following command to check and verify that Memcached service is running fine.
echo "stats settings" | nc localhost 11211
You can also verify if Memcached PHP extension is enable and working properly.You can do it by creating a phpinfo.php file.