We need fresh version of Redis, so we have to add dotdeb-sources, if they are not there yet:
deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all
cat dotdeb.gpg | apt-key add -
And now let's install Redis:
apt-get install redis-server
Now we need to edit redis.conf:
First of all, we have to change default level of logging to warning, otherwise log will be filled up by useless lines very fast - new line each 5 seconds:
Now, if you are going to use Redis as cacher, not as database, it will be good to set limit of allowed memory:
of course, it's optional.
And now let's set size of allowed swap-file:
size of page is 32, so 4194304 * 32 = 134217728 = 128 Mb
I think it should be enough. I don't like idea of swapping at all, and size of swap on my server is 256Mb :) Also, I know that VPS OpenVZ usually are deployed with 0 swap.
Using as a cacher
To use Redis in PHP you need client.
You can use PHP Memory Cacher with built-in client for Redis.
It will be easy:
$cacher = new \Jamm\Memory\RedisObject();