How to Install Redis on MacOS with Curl

Caching Caching
Curl Curl
macOS macOS
Redis Redis

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.

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.

Did You Enjoy the Tutorial?

Consider sending some love to Freddie the creator.

Comments (0)

You need to be logged in to comment..

Topics Mentioned in this Tutorial

Caching
3
0
0
Caching is a process in computing that stores data for future faster reference. The data stored in a cache yield faster result by storing a copy of an original query. Caching can be applied to both software and hardware....
Curl
1
0
0
Curl is a free and open-source command line tool and library for transferring data via URLs. Curl supports a wide variety of protocols and formats including DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS and more....
macOS
3
0
2
MacOS (Macintosh Operating System) is an operating system create by Apple for their line of laptops and desktop computers. MacOS features a sleek design with a global menu, dock and multi tasking features combined with the security and stability that so many has come to love. The operating system was first introduced in 1984 as Macintosh System Software, which later became System Software 2,3,4,5 and 6 the Mac OS 8,9. Then moved on to the OS X convention between 2001-2015 and now has settle with the current naming convention for the foreseeable future....
Redis
3
0
1
Redis is an open source in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes with radius queries and streams....