Windows and Mac Install Redis Guide

Posted on by Joseph Molloy | Updated:
Reading Time: 4 minutes

Installing Redis on macOS and Windows can get a little confusing. It’s not always clear which commands you should use and what you need to install beforehand to make Redis work.

Follow this step-by-step guide to simplify the process. Once you install Redis, there are tips on optimizing it and answering frequently asked questions.

What Is Redis?

Redis, short for Remote Dictionary Server, is an open source, in-memory datastore. You can use it as a fast database, application cache solution, streaming engine, and more. Redis is a highly reliable, fast, and high-performing solution thanks to its ability to store data in RAM.

When applications rely on external data sources, they experience a significant latency, limiting their performance. To work around this limitation and improve application performance, you can store and operate on its data in RAM instead, bringing it closer to the application.

This solution is where Redis shines. It stores all the necessary external data in RAM to deliver the highest possible read and write performance. Furthermore, it enables replication to place data physically closer to reduce latency.

Here are some core features of Redis:

  • Programmability using Lua and Redis Functions.
  • Module API for writing custom Rust, C, and C++ extensions.
  • Support for horizontal scalability with hash-based sharding.
  • Replication with automatic failover.
  • Ability to write to storage devices to survive shutdowns and reboots.

Install Redis on macOS

This section shows how to perform a macOS Redis installation. Start by installing Homebrew to make the whole process much easier.

Step 1: Install Xcode

Use the following command to install Xcode Command Line Tools. You will need this application to install Homebrew.

xcode-select --install

Step 2: Install Homebrew

Use the following command to download the Homebrew installation from its official Git repository. You will need it to install Redis.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Follow the terminal instructions to complete the installation. This process will mostly consist of clicking y to proceed further.

Step 3: Install Redis

Use the following command to install Redis.

brew install redis

Step 4: Start the Redis Service

Use the following command to activate the Redis service.

brew services start redis

If you see the startup logs in the output, you’ve successfully initiated Redis in the foreground.

Step 5: Test if Redis is Active

Use the following command to initiate the Redis command line.

redis-cli

If you see the following output, you’ve successfully initiated the Redis command line. The #.#.#.# represents your device’s IP, followed by a Redis port.

redis #.#.#.#:6379

Now, type in the following command to test if Redis is running.

ping

If Redis is installed properly and active, you should see the following output.

PONG

Install Redis on Windows

While there’s no official support for Redis on Windows, you can still use it for development. To install Redis on Windows, you’ll need to use the Windows Subsystem for Linux (WSL), available if you’re running either Windows 10 version 2004 (or later) or Windows 11.

The following instructions assume you’ve chosen a recent version of Ubuntu for your WSL. It is also possible to install Redis on Ubuntu 16.04 and 18.04.

Step 1: Install Ubuntu

Open the Command Prompt app by typing cmd in search on the taskbar and then click the app's icon. Now type in the following command to install Ubuntu and wait for it to complete.

wsl --install -d Ubuntu 22.04

It will ask you to set a username and password and log into the Ubuntu terminal.

Step 2: Update Package Information

Use the following command to get the latest package information from your configured package sources.

sudo apt-get update

Step 3: Install Redis

Use the following command to install Redis.

sudo apt-get install redis-server

Step 4: Start the Redis Service

Use the following command to activate the Redis service.

sudo service redis-server start

Step 5: Test if Redis is Active

Use the following command to initiate the Redis command line.

redis-cli

If you see the following output, you’ve successfully initiated the Redis command line. The #.#.#.# represents your device’s IP, followed by the Redis port.

redis #.#.#.#:6379

Now, type in the following command to test if Redis is running.

ping

If Redis is properly installed and active, you should see the following output.

PONG

Tips for Optimizing Redis

Here are some tips for optimizing Redis.

Limiting memory usage

By default, Redis will keep allocating RAM as much as necessary and eventually take up all of it, causing your machine to run out of RAM. To prevent this, we recommend defining a custom maxmemory value in the Redis configuration file called redis.conf. The below example shows a maxmemory value of 2GB expressed in bytes.

maxmemory 8589934592

Once you finish defining a custom memory limit, remember to restart the Redis service with the following commands.

If you’re using mac OS.

brew services restart redis

If you’re using Ubuntu.

sudo service redis-server restart

Making Redis Run on Startup

If you need Redis to start each time your operating system boots, follow the instructions below for your machine.

Use this command for mac OS.

ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents

This command is for Ubuntu.

systemctl enable redis-server.service

Conclusion

Redis is a fast and reliable application cache and database solution that you can apply to various use cases. Some of its core features include programmability in Lua, support for custom extensions, horizontal scalability, and replication with automatic failover. If you want to set it up on a macOS or Windows machine, this guide gets you up and running quickly.

Once you are ready to deploy your next website or web application, Liquid Web is here to help. Choose one of the VPS Hosting, Cloud Dedicated Server, or Dedicated Server options. Contact the sales team for assistance in choosing the best fit.

Redis FAQ

What is Redis?

Which operating systems does Redis support?

What happens when Redis runs out of memory?

Can Redis be configured to serve data from storage devices?

Avatar for Joseph Molloy

About the Author: Joseph Molloy

Liquid Web Security Operations tech Joseph spends his days cleaning up malware and doing his part to keep the Internet safe. He is interested in all things Linux and always looking for something new to learn. In addition, he enjoys cooking and playing guitar, is an avid horror and sci-fi reader, and is a fan of black metal music.

Latest Articles

How to use kill commands in Linux

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change the root password in WebHost Manager (WHM)

Read Article