Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Installation

Redis Installation

Installation on Windows

Download address:https://github.com/redis-windows/redis-windows/releases.

Redis supports 32-bit and 64-bit. You need to choose based on your system platform; here we download Redis-x64-xxx.zipthe archive to the C drive. After extracting, rename the folder to redis.

Open the folder; the contents are as follows:

Open a cmd window and use the cd command to change the directory to C:\redis Run:

redis-server.exe redis.windows.conf

For convenience, you can add the redis path to the system environment variables, so you don't have to type the path again; the redis.windows.conf at the end can be omitted, and if omitted, the default is used. After entering it, the interface below is displayed:

Now open another cmd window; do not close the original one, otherwise the server will become inaccessible.

Switch to the redis directory and run:

redis-cli.exe -h 127.0.0.1 -p 6379

Set the key-value pair:

set myKey abc

Get the key-value pair:

get myKey

Redis Installation


Linux Source Installation

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

The latest documentation version used in this tutorial is 2.8.17; download and install:



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

# tar -xzvf redis-6.0.8.tar.gz

# cd redis-6.0.8

# make

After running the make command, the compiled redis server program redis-server and the test client program redis-cli will appear in the src directory of redis-6.0.8:

Start the redis service below:



# cd src

# ./redis-server

Note that this way of starting redis uses the default configuration. You can also tell redis to use a specified configuration file via a startup parameter, using the command below.



# cd src

# ./redis-server ../redis.conf

redis.conf is a default configuration file. We can use our own configuration file according to our needs.

After starting the redis service process, you can use the test client program redis-cli to interact with the redis service. For example:



# cd src

# ./redis-cli

redis> set foo bar

OK

redis> get foo

"bar"


Ubuntu apt Command Installation

To install Redis on Ubuntu, you can use the following command:



# sudo apt update

# sudo apt install redis-server

Start Redis



# redis-server

Check whether redis is started?



# redis-cli

The above command will open the following terminal:



redis 127.0.0.1:6379>

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



redis 127.0.0.1:6379> ping

PONG

The above shows that we have successfully installed redis.