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 :)