DEV Community

Azza Maddouri
Azza Maddouri

Posted on

How to Install Redis on Windows Using WSL2

Redis is not officially supported on Windows. However, you can install Redis on Windows by enabling the Windows Subsystem for Linux (WSL2), which lets you run Linux binaries natively on Windows. In this brief tutorial, I'll guide you step by step to install Redis on Windows. 🚀

Step-by-Step Guide

  1. Enable WSL2:

    • Open PowerShell as an administrator and run:
     Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
    

PowerShell command to enable WSL2

  1. Install a Linux Distribution:

    • Launch the Microsoft Store by running:
     start ms-windows-store:
    

PowerShell command to launch Microsoft Store

  • Search for "Ubuntu" and install it.
    Search for Ubuntu in Microsoft Store

  • Open Ubuntu and enter a new Unix username and password when prompted.

  1. Set Up Redis:

    • Run the following commands in the Ubuntu terminal to install Redis:
     curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
    

Ubuntu terminal command to download Redis GPG key

 ```bash
 echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
 ```
Enter fullscreen mode Exit fullscreen mode

Ubuntu terminal command to add Redis repository

 ```bash
 sudo apt-get update
 ```
Enter fullscreen mode Exit fullscreen mode

Ubuntu terminal command to update package lists

 ```bash
 sudo apt-get install redis
 ```
Enter fullscreen mode Exit fullscreen mode

Ubuntu terminal command to install Redis

  1. Start the Redis Server:

    • After the installation is complete, start the Redis server with:
     sudo service redis-server start
    

Ubuntu terminal command to start Redis server

  1. Connect to Redis:

    • Test that your Redis server is running by connecting with the Redis CLI:
     redis-cli
     127.0.0.1:6379> ping
    

Redis CLI ping response

Congratulations! You've successfully installed Redis on Windows. 🎉 Happy coding! I hope this helps you! 😊

References

Top comments (0)