Below are the steps that I used to install Redis on my M1 Mac. The M1 Mac (and M2) uses the ARM64 architecture, but this is not a problem, as Redis versions 4.0 and above support the ARM architecture.
Install Homebrew (if required)
Seeing as we’re installing via Homebrew, this obviously requires that we have Homebrew installed.
You can check whether or not you have Homebrew installed by opening your Terminal window and entering the following:
brew --version
If that fails, you can install Homebrew by running this:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Alternatively, you can follow the instructions on the Homebrew website.
If you already have Homebrew installed, you might want to make sure you have the latest version before installing Redis. To do this, run the following:
brew update
Install Redis
Now that we know that Homebrew is installed, we can go ahead and install Redis:
brew install redis
That’s all that’s required. That command installs Redis.
Start Redis
You can run Redis in the foreground or in the background.
Run in the Foreground
To run Redis in the foreground, enter the following:
redis-server
In this case, Redis will start up and the Terminal will output a bunch of stuff.
To stop Redis, enter Ctrl-C
.
Run in the Background
To run Redis in the background, enter the following:
brew services start redis
That should produce something like this:
==> Successfully started `redis` (label: homebrew.mxcl.redis)
That uses launchd
to start the process in the background. You can check the status of the launchd
like this:
brew services info redis
Sample result:
redis (homebrew.mxcl.redis) Running: ✔ Loaded: ✔ Schedulable: ✘ User: barney PID: 29680
When running Redis like this, we can stop it with the following command:
brew services stop redis
Connect to Redis
If you stopped Redis at the previous step, be sure to start it again before running the following.
Now that Redis is up and running, we can go ahead and connect to it using the command line interface:
redis-cli
That launches the command line interface, and the result looks like this:
127.0.0.1:6379>
This means we’re ready to go.
The 127.0.0.1
part is my localhost, and the 6379
is the port number.
Run a Command
As mentioned, we’re ready to go. We can go ahead and run Redis commands and do whatever we need to do.
One quick command we can run is ping
:
ping
Result:
PONG
Yes, if you successfully ping Redis, the result is PONG
.
So to recap, we just installed Redis via Homebrew, connected to Redis, and then ran a command. Redis is now up and running.