Installing and running Redis on macOS can be done in several ways, including using Homebrew (a package manager for macOS), downloading and compiling from source, or running it as a Docker container. The simplest method for most users is via Homebrew.
-
Install Homebrew: If you don't already have Homebrew installed on your Mac, open the Terminal app and run the following command. This script installs Homebrew itself.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Follow the on-screen instructions to complete the installation.
-
Install Redis: Once Homebrew is installed, you can easily install Redis by running the following command in the Terminal:
brew install redis
-
Start Redis: After installing Redis, you can start it using Homebrew's services start command:
brew services start redis
This command will start Redis as a background service, which means Redis will automatically start every time you boot your computer unless you stop the service manually.
-
Verify Redis is Running: You can check that Redis is running correctly by using the
redis-cli
tool, which is a command-line interface to interact with Redis. Run theping
command, and you should receive aPONG
response if Redis is running:redis-cli ping
-
To stop the Redis service you started with Homebrew, run:
brew services stop redis
-
If you ever need to uninstall Redis, you can use Homebrew to remove it:
brew uninstall redis brew cleanup
-
To remove the Redis service from starting automatically, you can run:
brew services stop redis
This process installs Redis on your macOS and sets it up to run as a background service, making it easy to start working on applications that require Redis without having to manually start and stop the Redis server.