1 安装
参考:http://www.rabbitmq.com/download.html
homebrew安装
安装之前现更新homebrew
brew update
然后安装RabbitMQ server
brew install rabbitmq
安装完成后,终端会出现如下提示
Man pages can be found in:
/usr/local/opt/erlang/lib/erlang/man
Access them with `erl -man`, or add this directory to MANPATH.
==> rabbitmq
Management Plugin enabled by default at http://localhost:15672
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
To have launchd start rabbitmq now and restart at login:
brew services start rabbitmq
Or, if you don't want/need a background service you can just run:
rabbitmq-server
2 使用
RabbitMQ服务的脚本和CLI工具安装在/usr/local/sbin
目录下,该目录不在环境变量中,因此需要先把该目录添加到环境变量中,才能使用rabbitmq-server
命令。
临时添加
export PATH=$PATH:/usr/local/sbin
永久添加
Mac中可以通过修改以下几个文件来添加环境变量(按加载顺序排列):
/etc/profile
/etc/paths
~/.bash_profile
~/.bash_login
~/.profile
~/.bashrc
在此,我们修改~/.bash_profile
文件。
首先,打开文件:vi ~/.bash_profile
然后在文件末尾添加:export PATH=$PATH:/usr/local/sbin
启动RabbitMQ
- 前台运行
rabbitmq-server
- 后台运行
brew service start rabbitmq