Saturday, December 6, 2014

How To Install Memcached and Memcache Php Extensions In Ubuntu

What is Memcached?

     Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

     Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.

     Memcached is simple yet powerful. Its simple design promotes quick deployment, ease of development, and solves many problems facing large data caches. Its API is available for most popular languages.

To install Memcached in Ubuntu, continue with the steps below.
sudo apt-get install php5 php5-dev php5-memcached
Next, run the commands below to install Memcached
sudo apt-get install memcached
To start Memcached, run the commands below.
sudo service memcached start
To verify if Memcached is install and functioning, run the commands below to view its stats.
echo "stats settings" | nc localhost 11211 
The above command gives the following results.



























Live run-time stats can be viewed by running the commands below.
watch "echo stats | nc 127.0.0.1 11211" 






































This is how you install Memcached and its PHP extensions in Ubuntu.

To verify memcached installation via PHP, create a PHP test page with the code below.
sudo vi /var/www/info.php
Then type the code below in it and save.


<?
phpinfo(); ?>
Open your browser and browse to that page and you should see something like the image below.




Memcached default configuration file in Ubuntu is at

/usr/share/memcached/memcached.conf.default


If you wish to make changes to Memcached configuration, do it in this file. You can increase/decrease the memory, connection port, log file location many more settings in this file to control how Memcached operates.

No comments:

Post a Comment