Saturday, October 15, 2011

Install memcached with PHP on Ubuntu 11.04

Memcached is a great tool for optimising your website.  It can be used to cache commonly used data in memory for fast access.  This can help greatly in increasing speed, reducing DB load and scaling your site.  To find out more check out the memcached site here.

Here is a short guide to installing memcached on Ubuntu.  This is a guide to installing via the command line but if you prefer a GUI you can install via the Ubuntu Software Center.

Open a terminal(Ctrl + Alt + T) and enter the following:

sudo apt-get install memcached

sudo apt-get install php5-memcached

sudo /etc/init.d/apache2 restart

to test memcached is up and running enter:

telnet localhost 11211

if it connects you are good to go.
*Note to quit telnet enter Ctrl + ] then Ctrl + d then enter "quit" and hit enter.

To test that memcached is working with Apache and PHP see the instructions here