Installation
At the time of writing this book, the stable version of Redis was 3.0. All examples presented in this book will work with this version, but it is very likely that newer versions of Redis are going to work as well. Redis is very strict in terms of backward compatibility, so it provides API stability between minor versions. We recommend that you install the latest version of Redis to get the recent bug fixes and performance improvements. Most of the content in this book will remain useful even if you work with a more recent version.
Officially, Redis can be compiled and used on Linux, OS X, OpenBSD, NetBSD, and FreeBSD.
Redis is not officially supported on Windows. However, the Microsoft Open Tech group develops and maintains a Windows port targeting Win64 architecture, which can be found at https://github.com/MSOpenTech/redis. We are not going to cover Windows installation or guarantee that the examples presented in this book will work on Windows.
Installing from source
The first thing we need to do is open a terminal and run the following commands to download and install Redis. The following commands can be executed in any *nix operating system (Ubuntu, CentOS, Debian, OS X, and so on). Some build tools are required to build Redis from source (for example, gcc, make, and so on). On Ubuntu and Debian, these tools can be installed by the package build-essentials.
On OS X, you will need Xcode and Command Line Tools Package installed. After the required build tools are installed, open a terminal window and execute the following commands:
$ curl -O http://download.redis.io/releases/redis-3.0.2.tar.gz $ tar xzvf redis-3.0.2.tar.gz $ cd redis-3.0.2 $ sudo make install
Every time you see a dollar sign ($) at the beginning of a code block, it means we are executing the command in a terminal window.
Tip
Another way to install Redis is by using package managers, such as yum, apt, or brew. Make sure your package manager has Redis 3.0 or later available.