# How to install RabbitMQ on macOS  and Ubuntu 20.04

By Atta Ur Rehman Shah (https://attacomsian.com/about). Published Feb 8, 2021, updated Apr 12, 2021. Topics: Ubuntu, DevOps, macOS.
Canonical URL: https://attacomsian.com/blog/install-rabbitmq-macos-ubuntu

> A step-by-step guide to install and use RabbitMQ on macOS X and Ubuntu 20.04.

[RabbitMQ](https://www.rabbitmq.com/) is a popular message broker software used by tens of thousands of small startups and large companies worldwide.

It supports multiple messaging protocols, including Advanced Message Queuing Protocol (AMQP), Streaming Text Oriented Messaging Protocol (STOMP), MQ Telemetry Transport (MQTT), and other protocols.

The RabbitMQ server is written in the Erlang programming language and is built on the Open Telecom Platform (OTP) framework for clustering and failover.

RabbitMQ runs on many operating systems and cloud environments. In this article, you'll learn how to install and use the RabbitMQ server on macOS and Ubuntu machines.

## Installing RabbitMQ on MacOS

To install RabbitMQ on MacOS, you can use [Homebrew](https://attacomsian.com/blog/install-homebrew-macos) &mdash; a widely used package manager for macOS operating system.

RabbitMQ formula is available as part of the Homebrew's core tap. Run the following command to update Homebrew to its latest version:

```bash
$ brew update
```

Now you can install RabbitMQ with the following command:

```bash
$ brew install rabbitmq
```

RabbitMQ formula installation will also install all the required Erlang and OTP dependencies.

By default, RabbitMQ server and CLI tools are installed in the `/usr/local/Cellar/rabbitmq/<version>/sbin` directory. Symbolic links to binaries are also created under `/usr/local/sbin`. To access `rabbitmq-server` command from the command-line, add this directory to `PATH`:

```bash
$ export PATH=$PATH:/usr/local/sbin
```

To start the RabbitMQ server in the foreground, type the following command in your terminal:

```bash
$ rabbitmq-server start
```

To launch the RabbitMQ server in the background, you execute the following command:

```bash
$ brew services start rabbitmq
```

Optionally, if you want to access RabbitMQ in your browser, enable the management console plugin by typing the following command:

```bash
$ rabbitmq-server enable rabbitmq_management
```

Next, go to http://localhost:15672 to log into the RabbitMQ management console. The default username and password is guest:

![RabbitMQ Management Console Login Page](https://statics.attacomsian.com/gims/3212e150-9506-443d-9241-40769e819ec4.png)

Here is how the console looks like once you are logged in:

![RabbitMQ Management Console Overview](https://statics.attacomsian.com/gims/4f0d5330-250c-4bac-8b23-f504c0c1c7f2.png)

## Installing RabbitMQ on Ubuntu 20.04

RabbitMQ is included in standard Debian and Ubuntu repositories. However, the included versions are usually outdated and months or even years behind the latest RabbitMQ releases.

To install RabbitMQ on Ubuntu, Debian, and distributions based on one of them, you need to perform few additional steps.

### Step 1 &mdash; Update packages list

Run the following command to update the `apt` packages list:

```bash
$ sudo apt update
```

Also, install `curl` and `gnupg` packages if missing:

```bash
$ sudo apt install curl gnupg
```

### Step 2 &mdash; Import repository signing key

Execute the following command to import RabbitMQ repository signing key to `apt-key`:

```bash
$ curl -fsSL https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc | sudo apt-key add -
```

This command will instruct `apt` to trust packages signed by RabbitMQ key.

### Step 3 &mdash; Enable `apt` HTTPS transport

The `apt-transport-https` package must be installed on your Ubuntu machine to download RabbitMQ and Erlang packages from Bintray:

```bash
$ sudo apt install apt-transport-https
```

### Step 4 &mdash; Add PPA repository

Add the [PPA repository](https://launchpad.net/~rabbitmq/+archive/ubuntu/rabbitmq-erlang) for RabbitMQ and Erlang by typing the following command:

```bash
$ sudo add-apt-repository ppa:rabbitmq/rabbitmq-erlang
```

Press the `[Enter]` button when prompted to finish the import.

### Step 5 &mdash; Install RabbitMQ and Erlang

Now you're ready to install the RabbitMQ server and Erlang 23.x on your Ubuntu machine.

Type the following command to update the system packages list:

```bash
$ sudo apt update
```

Next, run the following command to install RabbitMQ and Erlang:

```bash
$ sudo apt install rabbitmq-server --fix-missing
```

Execute the following command to verify the installation:

```bash
$ erl -v
```

You should see the following output:

```bash
Erlang/OTP 23 [erts-11.1.7] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [hipe] [dtrace]
Eshell V11.1.7  (abort with ^G)
```

### Step 6 &mdash; Manage RabbitMQ service

RabbitMQ is installed as a systemd service. It means that you can manage it using standard systemd commands like `systemctl` or `service` on Ubuntu.

To start the RabbitMQ service, run the following command:

```bash
$ sudo service rabbitmq-server start
```

To check the current status of the RabbitMQ service, issue the following command:

```bash
$ sudo service rabbitmq-server status
```

You can stop the service anytime by typing:

```bash
$ sudo service rabbitmq-server stop
```

If you want to restart the service, use the following command:

```bash
$ sudo service rabbitmq-server restart
```

## Conclusion

That's all, folks! Today, you learned how to install and configure the popular message broker RabbitMQ on your macOS machine and Ubuntu 20.04 LTS server.
