安装rabbitMQ的前提是安装上erlang,所以从erlang安装开始。
安装erlang
1,先升级一下
$:sudo apt-get update
如果软件源有问题
修改etc/apt/sources.list内为如下:
# 国内源
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
2,下载erlang前确认安装了必要软件:
-
gcc
-
make
-
autoconf
-
libncurses-dev
$sudo apt-get install gcc make autoconf libncurses-dev
3,安装好后,安装erlang
$ sudo apt-get install erlang
4,安装公钥
wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -
5,再升级一下
$:sudo apt-get update
6,进入~/.bashrc添加erlang的路径为环境变量(erlang具体位置可以通过whereis erlang来找到,指定到bin目录即可)
添加内容(去除中括号):
【# 添加的erlang环境变量
export PATH=$PATH:/usr/lib/erlang/bin/】
7,配置完环境变量,刷新一下让配置生效
$ source ~/.bashrc
8,测试一下erlang,在bin目录外也可以生效,且运行语句正常。按ctrl+c 2次退出erlang。
输入:$ erl
执行如上语句即代表erlang安装并运行成功。
安装rabbitMQ
上述成功后
1,准备环境
$ curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.deb.sh | sudo bash
2,检查我们要装的rabbitmq版本。
$ apt-cache madison rabbitmq-server
通过上面erlang安装指导erlang版本是25,参考rabbitmq安装(https://www.rabbitmq.com/install-debian.html)知道需要的rabbitmq版本区间,如图:
3,选择对应版本
$ sudo apt-get install rabbitmq-server=3.11.21-1
完成后如图即安装成功。
4,安装完成后还需要配置一下才能登录rabbitmq
4.1 添加用户和密码,设置账号admin,密码 991201
$ sudo rabbitmqctl add_user admin 991201
4.2 将admin设置为管理员用户
$ sudo rabbitmqctl set_user_tags admin administrator
4.3 设置权限
$ sudo rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
4.4 启用插件
$ sudo rabbitmq-plugins enable rabbitmq_management
4.5 进入浏览器,输入http://localhost:15672/,在窗口输入设置的账号密码
进来了
至此完成!