使用 Homebrew 在 macOS 上安装 Redis 并通过 brew services 启动

我会把在 macOS 上使用 Homebrew 安装 Redis 并使用 brew services 启动的方法记下来。

使用Homebrew安装Redis

在安装Redis之前,先更新Homebrew到最新版本。

$ brew update
$ brew install redis

启动 Redis

本文介绍了如何使用Homebrew/homebrew-services来管理Homebrew服务。

Redis可以通过`brew services start redis`命令启动。

$ brew services start redis
==> Successfully started `redis` (label: homebrew.mxcl.redis)

通过使用brew services,就不再需要在macOS的launchctl中注册或取消注册plist文件。由于Redis会自动注册到launchctl中,因此请注意每次启动macOS时Redis会自动启动。

此外,还可以通过运行”brew services list”命令来检查启动状态。

$ brew services list
Name        Status  User   Plist
redis       started takuya /Users/takuya/Library/LaunchAgents/homebrew.mxcl.redis.plist

停止 Redis

可以用brew services stop redis命令来停止Redis。

$ brew services stop redis
Stopping `redis`... (might take a while)
==> Successfully stopped `redis` (label: homebrew.mxcl.redis)

文献引用

使用Homebrew在OS X上安装PostgreSQL并使用brew services启动。