Install Memcached on Ubuntu

 

Memcached on Ubuntu has actually two components. A standalone program running on your server and a  client PHP extension. To be honest I noticed no increase in performance using memcached with the W3 Total Cache plugin.

root@ns1:~# aptitude install memcached

The following NEW packages will be installed:

  memcached

 

First we need to install the PEAR framework. This is a distribution system for handling reusable PHP components.

 

root@ns1:~# aptitude install php-pear

The following NEW packages will be installed:

  php-pear php5-cli{a}

 

Now we can install the PHP component using PEAR.  Type YES to all options prompted.

root@ns1:~# pecl install memcache

...

Installing '/usr/lib/php5/20090626/memcache.so'

install ok: channel://pecl.php.net/memcache-2.2.6

configuration option "php_ini" is not set to php.ini location

You should add "extension=memcache.so" to php.ini

If you are using php5-fpm this will already be setup for you.
 
root@ns1:/etc/php5/fpm/conf.d# cat /etc/php5/fpm/conf.d/memcache.ini

; uncomment the next line to enable the module

extension=memcache.so

 

[memcache]

memcache.dbpath="/var/lib/memcache"

memcache.maxreclevel=0

memcache.maxfiles=0

memcache.archivememlim=0

memcache.maxfilesize=0

memcache.maxratio=0

Now let’s verify

root@ns1:/etc/php5/fpm/conf.d# pgrep -fl memcached

27823 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1

root@ns1:/etc/php5/fpm/conf.d# netstat -an | grep 11211

tcp        0      0 127.0.0.1:11211         0.0.0.0:*               LISTEN

udp        0      0 127.0.0.1:11211         0.0.0.0:*

 

Configuration Files

/etc/memcached.conf

- you can increase the amount of memory in the memcache pool in this file. The default is 64M, which should be sufficient.

 

Log Files

/var/log/memcached.log



About Danny W Sheehan

Danny has over 25 years in the IT industry and loves to blog about how to setup computer software, hardware, electronics and gadgets in general.

Subscribe

Subscribe to our e-mail newsletter to receive updates.

, ,

No comments yet.

Leave a Reply

CommentLuv badge