1

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.

3 Answers 3

1
+50

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

extension=memcache.so

and

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

to your php.ini (probably in /etc/php5/apache2/php.ini). Change the ip to your memcache server address or to 127.0.0.1 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.

1

I seem to recall having done this in the past by following the steps in this guide: http://stevelove.org/2009/09/30/how-to-install-php-memcached-on-an-ubuntu-server/

and possibly this one too.. http://blog.simonholywell.com/post/374206138/installing-apc-and-memcached-for-php-sessions-on-ubuntu

0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .