Install RabbitMQ on Ubuntu 20.04

RabbitMQ is a message broker that enables applications to communicate with each other and exchange information. It implements AMQP messaging protocol. RabbitMQ is an open-source project that is written by using Erlang programming language.

This tutorial shows how to install RabbitMQ on Ubuntu 20.04.

Install RabbitMQ

Add the Erlang repository:

sudo add-apt-repository -y ppa:rabbitmq/rabbitmq-erlang

Add the RabbitMQ repository:

wget -qO - https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.deb.sh | sudo bash

Install RabbitMQ:

sudo apt install -y rabbitmq-server

After installation is finished, we can check RabbitMQ server version:

sudo rabbitmq-diagnostics server_version

The following command can be used to determine if RabbitMQ service is running:

sudo service rabbitmq-server status

Also you can stop, start and restart the RabbitMQ service:

sudo service rabbitmq-server stop
sudo service rabbitmq-server start
sudo service rabbitmq-server restart

RabbitMQ provides web interface for monitoring and managing RabbitMQ server. It can be enabled with command:

sudo rabbitmq-plugins enable rabbitmq_management

By default, there is guest user with a default password of guest. Using this user you can only connect from localhost. To able to connect from remote hosts, you can create administrator user that has permissions in / virtual host:

sudo rabbitmqctl add_user admin pwd123
sudo rabbitmqctl set_user_tags admin administrator
sudo rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"

Testing RabbitMQ

Get the IP address of your machine:

hostname -I

By default, web service runs on 15672 port. Open the browser and enter IP address or hostname with port to access the RabbitMQ web interface.

RabbitMQ web interface on Ubuntu

Uninstall RabbitMQ

If you decided to completely remove RabbitMQ and related dependencies, run the following command:

sudo apt purge --autoremove -y rabbitmq-server

Remove GPG key and repository of the Erlang:

sudo rm -rf /etc/apt/trusted.gpg.d/rabbitmq_ubuntu_rabbitmq-erlang.gpg
sudo rm -rf /etc/apt/sources.list.d/rabbitmq-ubuntu-rabbitmq-erlang-focal.list

Remove GPG key and repository of the RabbitMQ:

sudo apt-key del 4D206F89
sudo rm -rf /etc/apt/sources.list.d/rabbitmq_rabbitmq-server.list

Remove the RabbitMQ user:

sudo deluser rabbitmq

Leave a Comment

Your email address will not be published.