Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm assuming memcache and memcached are two completely different things, and that I want to use memcached.

I have two separate servers (one is a webserver, one is meant for the db). I don't know which one would be better to keep memcached on.

Can someone explain to me the differences between memcached/memcache and the easiest way to install what is necessary? I keep seeing this libmemcached thing I'm supposed to download and compile or something? Seems like someone would have a working package for this sort of thing.

I'm using php, so php needs to be able to interact w/ it.

share|improve this question
up vote 1 down vote accepted

Memcached is the name of the Memcache daemon.

Using Memcache with PHP you are able to store PHP sessions in memory rather than in separate files on disk. This results in many times faster session management. This is especially useful when you've set up a load balancer and a few web app servers behind it but you plan to share sessions for each of your servers. You can run memcache on one of your servers or a separate server and make all your servers cache to the one running Memcache.

To get started:

sudo apt-get install memcached

Go through the config file in /etc/memcached/memcached.conf and see if the defaults are good for you.

Now install php's memcache client

sudo apt-get install php5-memcache

When asked, enable session handler support. Also, add


session.save_handler = memcache
session.save_path = "tcp://"

to your php.ini (probably in /etc/php5/apache2/php.ini). Change the ip to your memcache server address or to if you run it locally.

Start the service with

/etc/init.d/memcached start

Before installing anything, you really should read up on what the package does otherwise you will not be able to get the most out of it.

share|improve this answer

I seem to recall having done this in the past by following the steps in this guide:

and possibly this one too..

share|improve this answer

Memcached is cool, rocket fast. But I would advise you to checkout redis ( ) - performance is close to the same. But it has a lot more features.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.