Redis is a popular open-source, in-memory data store that can be used as a database, message broker, or cache layer. While Redis is primarily designed for Linux and Unix-like systems, it can also be run on Windows. In this tutorial, we will explore the different ways to install and run Redis on Windows.
Installing Redis using MSOpenTech’s Port
One of the most popular and up-to-date ports of Redis for Windows is provided by MSOpenTech. You can download the latest version of Redis from their GitHub repository. Here are the steps to follow:
- Download the latest Redis-x64 zip file from the MSOpenTech/redis releases page.
- Extract the zip file to a directory of your choice, such as
C:\Redis
. - Open a command prompt or PowerShell window and navigate to the extracted directory.
- Run the
redis-server.exe
command to start the Redis server. - To connect to the Redis server, run the
redis-cli.exe
command.
Installing Redis using Windows Subsystem for Linux (WSL)
If you are running Windows 10 or later, you can also install Redis using the Windows Subsystem for Linux (WSL). Here are the steps to follow:
- Enable WSL by opening PowerShell as an administrator and running the command
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
. - Restart your computer after enabling WSL.
- Open the Microsoft Store and search for "Ubuntu" or your preferred Linux distribution.
- Install Ubuntu or your chosen distribution.
- Once installed, open Ubuntu and run the following commands to install Redis:
sudo apt-add-repository ppa:redislabs/redis
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install redis-server
- Restart the Redis server by running
sudo service redis-server restart
. - Verify that Redis is running by using the
redis-cli
command.
Running Redis as a Windows Service
To run Redis as a Windows service, you can use the RedisWatcher tool provided by MSOpenTech. Here are the steps to follow:
- Download the RedisWatcher binaries from the MSOpenTech/redis repository.
- Extract the zip file to a directory of your choice, such as
C:\RedisWatcher
. - Run the
InstallWatcher.msi
command to install the RedisWatcher service. - Open the Windows Services console and start the Redis watcher service.
Verifying Redis Installation
Once you have installed Redis using one of the above methods, you can verify that it is running by using the redis-cli
command. Here are some example commands to try:
$ redis-cli
127.0.0.1:6379> set user:1 "John"
OK
127.0.0.1:6379> get user:1
"John"
This should confirm that Redis is installed and running correctly on your Windows machine.
Conclusion
In this tutorial, we have explored the different ways to install and run Redis on Windows. Whether you choose to use MSOpenTech’s port, WSL, or run Redis as a Windows service, you can now take advantage of Redis’s powerful in-memory data store capabilities on your Windows machine.