redis installed on windows subsystem for linux with a python app

Today in this article, we shall see how to run Redis on Windows. We shall run Redis Server and default available Redis client on Windows machine to verify Redis cache is configured correctly.

Today in this article, we will cover below aspects,

There are multiple ways by which you can install Redis on your Windows machine. Recently, I tried a few different ways, but I ran into a few issues with Redis version compatibility and other errors.

Finally, I choose to adopt WSL, which is a basic approach to run easily on the Windows subsystem for Linux.

What is WSL?

WSL is Windows Subsystem for Linux.

Benefits of WSL

  • It allows developers to execute Linux environments on Windows without the need for virtual machines or other configurations.
  • WSL gives you support for most of the command-line tools, utilities, and applications used on Linux example bash, ssh, git, apt.

Run Redis on Windows setup

Please follow below basic steps below.

Step 1: Enable Microsoft-Windows-Subsystem-Linux on the windows machine

The Enable-WindowsOptionalFeature cmdlet enables or restores an optional feature in a Windows image.

Run Powershell in Administrator mode and run the below command

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

If not used in admin mode might get the below error,

Above specify the running operating system on your local computer with the Online option

The above command should take a few minutes to enable this feature.

Run Unix commands on windows redis windows

Please restart the machine for the configuration to be effective.

Step 3: Download and install Linux distros using Ubuntu/Debian

You can install Linux distros using the Ubuntu app available on the Microsoft store.

Ubuntu on Windows allows one to use Terminal and run Ubuntu command line utilities including bash, ssh, git, apt, etc.

Install Debian GNU/Linux on Windows

run debian command on windows and run redis on windows

OR

Install Ubuntu 18.04 on Windows

run ubuntu command on windows redis server windows

Once Ubuntu is installed successfully, please configure the default user account to run the required apt commands

enable ubuntu command on windows redis client windows

Please run the below commands to get the latest updates if any,

> sudo apt-get update

> sudo apt-get upgrade

Install Redis Server and Client- Windows

Let’s install now Redi server now using the sudo apt command,

sudo apt-get install redis-server

sudo apt get install redis server

For any issue please restart the Redis Server,

sudo service redis-server restart

Redis client validation – Windows

Command

SET key value [EX seconds|PX milliseconds|EXAT timestamp|PXAT milliseconds-timestamp|KEEPTTL] [NX|XX] [GET]

Run Redis on Windows

As we can see Redis port for Windows 6379 is used. Above we are setting a new key and retrieving the key from the cache.

That’s all, you are all set to use the Linux command on the window machine. Hope you find this useful.

Do you have any comments or ideas or any better suggestions to share?

Please sound off your comments below.

Happy Coding !!



Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.



Leave a Reply

Your email address will not be published. Required fields are marked *