
Installing Redis on Mac OS
Installing Redis is really simple on a Mac OS. Follow these steps and you are good to go:
- Download the package from Internet. For this, you can use the following command:
wget http://download.redis.io/releases/redis-2.8.3.tar.gz
- Untar the compressed
tar xzf redis-2.8.3.tar.gz
file. - This will create a folder; go to the folder by issuing the
cd redis-2.8.3
command. - Compile the file by issuing the
make
command. This will compile the binaries and create a folder structure, as shown in the following screenshot:Folder structure for a Mac distribution
- Type the
src/redis-server
command; this will start the server, as shown in the following screenshot:Starting the Redis server in the Apple environment
- Your Redis server is running and it is ready to accept the requests in port 6379. Open another terminal and go the same folder form where you installed Redis. Type the command
src/redis-client
; this will start the client shell, as shown in the following screenshot:Redis client started in Apple environment
- Your client is ready and you are ready for the Hello World program, but before you continue, it's better to understand a bit more about the configuration file called
redis.conf
.
Introduction to redis.conf
Redis ships with the redis.windows.conf
file, which is located in the parent folder that was created when the distribution's ZIP/tarfile was uncompressed. Any customization needed by the server on startup can be done through this configuration file. If you need to include the redis.conf
file, then provide the path to the file while the server starts up as an argument.
The following message will be displayed on the Command Prompt when you provide the configuration file at startup:

Redis server startup with config path during the startup
Redis, as mentioned, is a Unix-based software, which is ported to the Windows environment. A lot of configuration parameters are meant for the Unix environment; nevertheless, it is always good to know about the parameters that will be beneficial to you when moving to a Unix-based environment. These parameters are explained as follows:
- Port 6379: This number indicates that the server will listen to messages coming on port 6379. This port number can be changed to suit your project setup, and the server will listen for messages on that port. This will require a server restart.
- # bind 127.0.0.1: This is the IP address that you want your server to bind to. By default, this parameter is commented, which means that the server will listen to all the interfaces for messages.
- Timeout 0: This means that the server will not close the connection if the client is in an idle state.
- tcp-keepalive 0: This is a command to the server in order to keep the connection with the client open. You can make it
SO_KEEPALIVE
, which will indicate the server to send anACK
message to the client. - loglevel notice: This is the log level that you want your server to have. The levels of logs that you can have are debug, verbose, notice, and warning.
- logfile stdout : This is the channel to which you want to send your log messages, to the command line in Windows or the terminal in the case of Unix-based systems.
- syslog-enabled no: If this is changed to yes, this will send the message to the system log.
- dir: This should be set to the working directory where the user wants to run the Redis server. This in turn will tell the Redis server to create files, such as server files appropriately.
Rest of the configuration parameters can be treated as advanced parameters, and we shall be using most of them in subsequent chapters when the need arises.