How to install Memcached on Ubuntu


Memcached is a system daemon that allows you to cache information on RAM memory, this allows you better app speeds and avoid bad performance on your dedicated or vps server. Memcached works at system level, however you can use Memcached with many programming languages in order to optimize your apps. On this example I will show you how to install memcached on Ubuntu with the php-memcache extension.

Memcached Pre requisites

Ensure all packages are up to date

sudo apt-get update

Installing PHP basic modules, along with compilers

sudo apt-get install mysql-server php5-mysql php5 php5-memcache build-essential

Install Memcached

sudo apt-get install memcached

Installing php-pear (this is where we will get memcache module)

sudo apt-get install php-pear

Install memcache php extension using PECL

sudo pecl install memcache

If the PECL installation asks this question:

"Enable memcache session handler support? [yes]"

Just type enter in order to continue without issues.

Last step: add your new module to PHP memcache.ini file:

touch /etc/php5/conf.d/memcache.ini echo "" >> /etc/php5/conf.d/memcache.ini

Start memcached

sudo service memcached start

Reload your PHP server to load the memcached extension

If you use php-fpm:

sudo service php5-fpm reload

If you use Apache:

sudo service apache2 reload

Test memcached

ps aux | grep memcache

You should see something like this:

memcache 14289 0.0 0.0 38358 1172 ? Sl 06:15 0:00 /usr/bin/memcached -m 64 -p 11211 -u memcache -l

Remember to configure memcached at system level from:


Related Posts

Recommended:  Install GitBucket on Ubuntu 16.04

Leave a Reply