How to Install Redis on MacOS with Curl

How to Install Redis on MacOS with Curl

Redis a fantastic free and open-source in-memory key-value database that can be used to cache your web app to improve both performance and resource consumption. Today I will go over how we can install and run Redis locally on your Mac.

Installing Redis for macOS is not as straight forward as downloading a .dmg and clicking it. However, we have a few options available to choose from. We can download the binary from the download section of redis.io, or use homebrew, wget or Curl.

Personally, I am not a big fan of homebrew, even though it might be the most common way of downloading packages via the terminal for mac. So I thought I'd share how we can install Redis using Curl.

Quick Explanation

Here is a quick overview of the commands used to install Redis with Curl for mac. the less seasoned developers can find a more in-depth section below.

mkdir redis && cd redis

curl -O http://download.redis.io/redis-stable.tar.gz

tar xzvf redis-stable.tar.gz

cd redis-stable

make

make test

sudo make install

1. Create a folder for Redis and navigate to it

Open up a new terminal window and run the command..

mkdir redis && cd redis

This command will create a folder in your user folder (/Users/username) called "redis" and then navigate to it.

2. Download the stable Redis tar.gz with Curl

curl -O http://download.redis.io/redis-stable.tar.gz

3. Unpack redis-stable.tar.gz

tar xzvf redis-stable.tar.gz

4. Navigate to the unpacked redis-stable folder

cd redis-stable

5. Compile Redis

With the make command we can compile the binaries.

make

6. Test the compilation

With the make test you can verify that everything was built correctly. Be away that the test can take a few minutes to run..

Testing integration/aof
[ok]: Unfinished MULTI: Server should start if load-truncated is yes
[ok]: Check for memory leaks (pid 10969)
[ok]: Short read: Server should start if load-truncated is yes
[ok]: Truncated AOF loaded: we expect foo to be equal to 5
[ok]: Append a new command after loading an incomplete AOF
[ok]: Check for memory leaks (pid 10985)
[ok]: Short read + command: Server should start
[ok]: Truncated AOF loaded: we expect foo to be equal to 6 now
[ok]: Check for memory leaks (pid 11001)
[ok]: Bad format: Server should have logged an error
[ok]: Unfinished MULTI: Server should have logged an error
[ok]: Short read: Server should have logged an error
[ok]: Short read: Utility should confirm the AOF is not valid
[ok]: Short read: Utility should be able to fix the AOF
[ok]: Fixed AOF: Server should have been started
[ok]: Fixed AOF: Keyspace should contain...

If make test was successfull you should be greeted with...

\o/ All tests passed without errors!

7. Finally install Redis

We are almost finished, as it is time to install Redis, we can do so with the command..

sudo make install

If your terminal is outputting 5 lines of "INSTALL install" you should be good to go!

INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install

8. Verify that everything is setup correctly

Now when everything is installed you should be able to start your Redis server with the command..

redis-server

.. and be greetd with the following prompt :D

                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 5.0.9 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 12192
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

12192:M 26 Apr 2020 11:14:27.094 # Server initialized
12192:M 26 Apr 2020 11:14:27.095 * Ready to accept connections

You should now also have access to the redis CLI.

redis-cli

which should give you your redis-servers IP...

127.0.0.1:6379>

.. and to be 100% that everything is good you can ping it.

127.0.0.1:6379> ping

And you will be greated with a PONG.

PONG

That's really all there is to it! In the next tutorial regarding Redis I will dig deeper into how we can use it as a key-value store Cache for Django ORM.

Freddie Freddie 4 years, 8 months ago 0
Login to Comment
No comments have been posted yet, be the first one to comment.
How to Install Deno on macOS
How to Install Deno on macOS
Deno is a simple, modern and secure runtime for JavaScript and TypeScript, by the creator of Node.js himself, Ryan Dahl. Deno uses the Chrome v8 engine and is built with Rust. The project just reach version 1.0 and got many people in the JavaScript community interested. In this tutori...
How to Install & Setup Redis for Dokku
How to Install & Setup Redis for Dokku
Redis is a free and open-source in-memory data store which can be used as cache or in same cases even a database. Redis is super simple to install if you manage your applications with your own Dokku PaaS (Platform as a Service). In today's tutorial I will show you how we can install a...
Create, Access and Use SSH Keys with macOS
Create, Access and Use SSH Keys with macOS
SSH or "Secure Shell" is a network protocol for operating networked services securely. It is typically used for remote command-line authentication and command execution. In this tutorial I will show you how you can create, access and use your SSH key for macOS. 1. Open Termi...