Published on

Install Redis on Different Operating Systems

Authors
  • avatar
    Name
    Hieu Cao
    Twitter

Introduction

Redis is a versatile NoSQL database used for caching, session storage, and real-time analytics. This guide explains how to install Redis on macOS, Linux, and Windows for local and server environments.


Installation on macOS

Using Homebrew

  1. Update Homebrew:

    brew update
    
  2. Install Redis:

    brew install redis
    
  3. Start Redis Server:

    brew services start redis
    
  4. Verify Installation:

    redis-cli ping
    

    The response should be PONG.


Installation on Ubuntu

Using APT Package Manager

  1. Update Package Index:

    sudo apt update
    
  2. Install Redis:

    sudo apt install redis-server
    
  3. Enable Redis to Start on Boot:

    sudo systemctl enable redis
    
  4. Start Redis Server:

    sudo systemctl start redis
    
  5. Check Status:

    sudo systemctl status redis
    
  6. Verify Installation:

    redis-cli ping
    

Installation on Windows

Using Windows Subsystem for Linux (WSL)

  1. Enable WSL:

    • Open PowerShell as Administrator and run:
      wsl --install
      
  2. Install a Linux Distribution (e.g., Ubuntu):

    • Launch the Microsoft Store and install Ubuntu.
  3. Install Redis on Ubuntu (WSL): Follow the Ubuntu instructions above.

  4. Start Redis:

    redis-server
    
  5. Connect Using Redis CLI:

    redis-cli ping
    

Common Commands to Start and Stop Redis

Starting Redis Server

  • On macOS:
    brew services start redis
    
  • On Linux:
    sudo systemctl start redis
    

Stopping Redis Server

  • On macOS:
    brew services stop redis
    
  • On Linux:
    sudo systemctl stop redis
    

Conclusion

Installing Redis on your local or server environment is straightforward and supports various operating systems. Whether you’re using macOS, Linux, or Windows, these steps will help you set up Redis efficiently.

Redis is now ready to be used for caching, real-time analytics, and more. Explore its features and build powerful applications!