In this section, we will cover the steps required to install Redis on different operating systems. By the end of this module, you will have Redis up and running on your machine, ready for you to start exploring its features.

Table of Contents

Installing Redis on Linux

Using Package Manager (Ubuntu/Debian)

  1. Update your package list:

    sudo apt update
    
  2. Install Redis:

    sudo apt install redis-server
    
  3. Start Redis server:

    sudo systemctl start redis-server
    
  4. Enable Redis to start on boot:

    sudo systemctl enable redis-server
    

Using Package Manager (CentOS/RHEL)

  1. Add the EPEL repository:

    sudo yum install epel-release
    
  2. Install Redis:

    sudo yum install redis
    
  3. Start Redis server:

    sudo systemctl start redis
    
  4. Enable Redis to start on boot:

    sudo systemctl enable redis
    

Building from Source

  1. Install build dependencies:

    sudo apt update
    sudo apt install build-essential tcl
    
  2. Download the latest stable version of Redis:

    curl -O http://download.redis.io/redis-stable.tar.gz
    
  3. Extract the tarball:

    tar xzvf redis-stable.tar.gz
    
  4. Compile Redis:

    cd redis-stable
    make
    
  5. Run the Redis test suite:

    make test
    
  6. Install Redis:

    sudo make install
    

Installing Redis on macOS

Using Homebrew

  1. Install Homebrew if you haven't already:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  2. Install Redis:

    brew install redis
    
  3. Start Redis server:

    brew services start redis
    
  4. Stop Redis server (if needed):

    brew services stop redis
    

Installing Redis on Windows

Using Redis for Windows

  1. Download the latest Redis MSI installer from the Microsoft Open Tech Group's GitHub repository.

  2. Run the installer and follow the prompts to complete the installation.

  3. Start Redis server:

    • Open Command Prompt as Administrator.
    • Navigate to the Redis installation directory.
    • Run the following command:
      redis-server
      

Verifying the Installation

  1. Open a terminal or command prompt.

  2. Run the Redis CLI:

    redis-cli
    
  3. Ping the Redis server to check if it's running:

    127.0.0.1:6379> PING
    
  4. You should receive a response:

    PONG
    

Conclusion

In this section, we covered how to install Redis on various operating systems including Linux, macOS, and Windows. We also verified the installation to ensure that Redis is running correctly. In the next module, we will explore the basic data types in Redis and how to interact with them using the Redis CLI.

© Copyright 2024. All rights reserved