How to Install Redis on Windows with WSL
By FoxLearn 12/18/2024 9:26:27 AM 35
Redis, which runs natively on Linux-based operating systems, can also be installed and run on Windows 10/11 using Windows Subsystem for Linux (WSL). This article provides a step-by-step guide on how to install Redis on Windows using WSL.
What is Redis?
Redis (Remote Directory Server) is an open-source, in-memory NoSQL data store, primarily used as an application cache or a fast-response database. It is widely used by developers and system administrators to enhance the performance and scalability of applications.
What is WSL?
WSL (Windows Subsystem for Linux) is a compatibility layer that allows Linux binary executables to run natively on Windows. It provides a lightweight Linux environment on Windows, allowing users to run Linux command-line tools and applications directly without the need for a virtual machine or dual-boot setup.
How to Install Redis on Windows 10/11 Using WSL?
Step 1: Turn on Windows Subsystem for Linux
Before installing Redis on Windows, we need to enable the Windows Subsystem for Linux (WSL), a compatibility layer that allows running Linux binaries on Windows 11 and Windows Server 2019.
To enable WSL, open PowerShell as Administrator and run the appropriate command.
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
After running the command to enable WSL, you need to reboot your system.
You can also install the Windows Subsystem for Linux (WSL) by using 'Turn Windows features on or off.'
- Open the Control Panel.
- Select "Turn Windows features on or off".
- In the Windows Features window, scroll down and check the box for Windows Subsystem for Linux.
Click OK, then restart your computer if prompted to apply the changes.
Step 2: Launch Microsoft Windows Store
Once WSL is enabled, open the Microsoft Store, search for your preferred Linux distribution (e.g., Ubuntu), and download the latest version. Wait for the installation to complete.
Once installed, open your chosen Linux distribution from the Start menu (e.g., "Ubuntu"), then set up your Linux user and password when prompted.
Step 3: Install the Redis server on Windows WSL
After installation, you can run Bash on Ubuntu by typing "bash" in a Windows Command Prompt. To install the latest version of Redis, you first need to install some prerequisites.
sudo apt-add-repository ppa:redislabs/redis sudo apt-get update sudo apt-get upgrade sudo apt-get install redis-server
Note that the sudo
command may be required depending on your system's user configuration.
You can also run the latest version of Redis with Vagrant
What is Vagrant?
Vagrant is a source-available software tool for building and maintaining portable virtual development environments, supporting platforms like VirtualBox, KVM, Hyper-V, Docker, VMware, and AWS. It simplifies software configuration management for virtualization, boosting development productivity.
How to Install Vagrant on Windows?
Binary download for AMD64: Download
Binary download for I686: Download
Run the installer for your system, which will automatically add Vagrant to your system path, making it available in terminals.
Next, Download the vagrant-redis.zip vagrant configuration
wget https://raw.github.com/ServiceStack/redis-windows/master/downloads/vagrant-redis.zip
Extract the vagrant-redis.zip
file to a folder, such as c:\vagrant-redis
, and then launch the VirtualBox VM by running vagrant up
.
cd c:\vagrant-redis vagrant up
This will launch a new Ubuntu VM in VirtualBox, which will automatically install and start the latest stable version of Redis.
Step 4: Restart the Redis server on Windows WSL
After installing Redis, restart the Redis server by running the appropriate command.
sudo service redis-server restart
Step 5: Verify if your Redis server is running on Windows WSL
You can test the connectivity to the Redis database by using the redis-cli
command. Run this command to launch the Redis command-line interface.
redis-cli
If you want to stop the Redis server, run the following command:
sudo service redis-server stop
To start the Redis server on your system, you can run the following command:
sudo service redis-server start
This will start the Redis server if it is installed on your system. If you're using Ubuntu or another Linux distribution, the command should work as expected. To verify that the Redis server is running, you can use:
redis-cli ping
If Redis is running, it will return PONG
.