Skip to content

Instantly share code, notes, and snippets.

@jason-shen
Created May 6, 2018 19:34
Show Gist options
  • Save jason-shen/75e803311345d1d2d71bb7dc89aab7c5 to your computer and use it in GitHub Desktop.
Save jason-shen/75e803311345d1d2d71bb7dc89aab7c5 to your computer and use it in GitHub Desktop.
Install Redis on macOS Sierra via Homebrew

Install Redis on macOS Sierra via Homebrew

It's very simple to install Redis on macOS. Just follow the instructions below.

For the first you need to install Homewbrew. Then run the command below in you Terminal:

$ brew install redis

To get all info about this package run:

$ brew info redis

For the next, you should setup your LaunchAgent to run Redis server when computer starts:

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

To run Redis server via launchctl, use this command:

$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

To stop it, run this command:

$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

For easy control of Redis server you could add last two commands to your aliases list. Just open your .bash_aliases and add this 3 lines:

$ alias redis.start='launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist'
$ alias redis.stop='launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.redis.plist'
$ alias redis.restart='redis.stop && redis.start'

Then update your .bash_profile:

$ echo "source ~/.bash_aliases" >> ~/.bash_profile && . ~/.bash_profile

If you don't have .bash_aliases file, just watch this guide, to find out how to create it.

To test Redis connection run:

$ redis-cli ping
PONG

That's all. All other information about Redis, you could find on Redis official site. Follow RTFM :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment