Easy Tutorial
❮ Redis Commands Server Save ❯

Redis Installation

Installation on Windows

Download Link: https://github.com/tporadowski/redis/releases.

Redis supports both 32-bit and 64-bit systems. Choose the appropriate version based on your system platform. Here, we download the Redis-x64-xxx.zip package to the C drive, unzip it, and rename the folder to redis.

Open the folder, which contains the following:

Open a cmd window and use the cd command to switch to the C:\redis directory and run:

redis-server.exe redis.windows.conf

For convenience, you can add the redis path to the system environment variables, so you don't need to enter the path each time. The redis.windows.conf can be omitted; if omitted, the default configuration will be used. After entering the command, the following interface will be displayed:

Now, open another cmd window without closing the original one, otherwise, you won't be able to access the server.

Switch to the redis directory and run:

redis-cli.exe -h 127.0.0.1 -p 6379

Set a key-value pair:

set myKey abc

Retrieve the key-value pair:

get myKey

Source Code Installation on Linux

Download Link: http://redis.io/download, download the latest stable version.

This tutorial uses the latest documentation version, 2.8.17. Download and install:

# wget http://download.redis.io/releases/redis-6.0.8.tar.gz
# tar xzf redis-6.0.8.tar.gz
# cd redis-6.0.8
# make

After running the make command, the src directory of redis-6.0.8 will contain the compiled redis server program redis-server, and a client program redis-cli for testing:

Start the redis service:

# cd src
# ./redis-server

Note that this method starts redis with the default configuration. You can also specify a configuration file using the following command:

# cd src
# ./redis-server ../redis.conf

redis.conf is a default configuration file. We can use our own configuration file as needed.

After starting the redis service process, you can interact with the redis service using the test client program redis-cli.

For example:

# cd src
# ./redis-cli
redis> set foo bar
OK
redis> get foo
"bar"

Ubuntu apt Command Installation

To install Redis on Ubuntu, use the following commands:

# sudo apt update
# sudo apt install redis-server

Start Redis

# redis-server

Check if Redis is running

# redis-cli

The above command will open the following terminal:

redis 127.0.0.1:6379>

127.0.0.1 is the local IP, and 6379 is the redis service port. Now, enter the PING command.

redis 127.0.0.1:6379> ping
PONG

This indicates that we have successfully installed redis.

❮ Redis Commands Server Save ❯