This guide provides the step-by-step commands to install Redis on your computer for development purposes. It’s the official companion to our tutorial video.
Installing Redis on Windows
For Windows, you have a couple of excellent options. The method we use in the video is WSL, but the native Memurai installer is also a great choice. You can use Docker instead of WSL, you just need to set up a linux environment in the docker then the process is the same as the linux process.
Method 1: WSL (Recommended for this Tutorial Series)
The Windows Subsystem for Linux (WSL) lets you run a real Linux environment directly on Windows. This is the method recommended by the official Redis documentation because you get to run the actual Linux version of Redis, which is what you’ll almost always use on a real server.
Step 1: Install WSL
- Right click on the Start icon.
- Select Terminal (Admin).
- Select yes when prompted.
-
In the PowerShell window that appears, type the following command and press Enter:
wsl --install
-
This will automatically download and install WSL along with the default Ubuntu distribution. Once it’s finished, restart your computer.
Step 2: Set Up Linux
- After restarting, find “Ubuntu” in your Start Menu and open it.
or - Run a terminal and type wsl into it
- The first time it runs, it will ask you to create a username and a password. This is only for your new Linux environment. Complete this setup.
Step 3: Install Redis in Ubuntu
-
Now that you have a Linux terminal running, copy and paste the following commands as they are and press Enter.
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg 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 sudo apt-get update sudo apt-get install redis
(Note: We use the
sudo
command because installing software and managing services requires administrator privileges in Linux.)
Step 4: Start the Redis Server
-
To start the Redis service, use the following command:
sudo service redis-server start
-
Incase you need to stop Redis, use the command:
sudo service redis-server stop
You’re all set! Skip to the “Verifying Your Installation” section.
Method 2: Memurai (Native Windows Alternative)
Memurai is the official Redis partner for providing a native Windows version. It’s an excellent choice if you prefer a simple .msi
installer and don’t want to set up WSL.
- Download: Go to the Memurai Download Page.
- Select Edition: Download the Memurai Developer Edition, which is free.
- Install: Run the installer just like any other Windows application. It will set up Redis to run automatically as a Windows service.
Installing Redis on macOS
For macOS, the easiest way to install Redis is with a package manager called Homebrew.
Step 1: Install Homebrew (if you don’t have it)
- Open your Terminal application.
-
Paste the following command and press Enter:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Install Redis
-
In the same terminal, run:
brew install redis
Step 3: Start the Redis Server
-
To have Redis start automatically every time you log in, run:
brew services start redis
-
To stop Redis, use the command:
brew services stop redis
Verifying Your Installation
This process is the same for all operating systems.
- Open your command line tool (Terminal, or your Ubuntu WSL terminal).
-
Type the following command to connect to your running Redis server:
redis-cli
-
You should see your prompt change to
127.0.0.1:6379>
. -
To test the connection, type
PING
and press Enter. You should see aPONG
response.127.0.0.1:6379> PING PONG
Congratulations, Redis is working!
A Few Fun Commands to Try
# Set a key named "message" with the value "hello redis"
127.0.0.1:6379> SET message "hello redis"
OK
# Get the value of the key "message"
127.0.0.1:6379> GET message
"hello redis"
# Check if a key named "message" exists (1 means yes, 0 means no)
127.0.0.1:6379> EXISTS message
(integer) 1
# Delete the key
127.0.0.1:6379> DEL message
(integer) 1
# Check again if it exists
127.0.0.1:6379> EXISTS message
(integer) 0
To exit the Redis CLI, type exit
or press Ctrl+C
.
What’s Next?
Now that you have Redis installed, you’re ready to dive into the core of its power: data types! In our next video/article, we’ll cover the fundamental data types in Redis.
For more in-depth information, you can always refer to the Official Redis Documentation.