Install RabbitMQ on Ubuntu 22.04

Install RabbitMQ on Ubuntu 22.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 22.04.

Install RabbitMQ

Add the Erlang repository:

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

Add the RabbitMQ repository:

wget -qO - | 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 a 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 a user with a default password of guest. Using this user, you can only connect from localhost. To be able to connect from remote hosts, you can create an 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-jammy.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

Cancel reply

Your email address will not be published.