Install RabbitMQ Server on Ubuntu 22.04|20.04|18.04

Posted on 11 views

RabbitMQ is an open source message broker software that implements the Advanced Message Queuing Protocol (AMQP) and Streaming Text Oriented Messaging Protocol, Message Queuing Telemetry Transport, and other protocols via a Plugins.

The work of a Messaging broker is to receive messages from publishers (applications that publish them) and route them to consumers (applications that process them). AMQP is a messaging protocol that enables conforming client applications to communicate with conforming messaging middleware brokers.

Follow the steps below to install RabbitMQ Server on Ubuntu 22.04|20.04|18.04 LTS.

Step 1: Install Erlang/OTP

RabbitMQ requires Erlang to be installed first before it can run. Install Erlang on Ubuntu 22.04|20.04|18.04 system using our previous guide:

Once Erlang has been installed, proceed to step 2.

Step 2: Add RabbitMQ Repository to Ubuntu

Team RabbitMQ maintains an apt repository on PackageCloud, a package hosting service. It provides packages for most recent RabbitMQ releases.

Let’s add RabbitMQ Repository to our Ubuntu system.

curl -s | sudo bash

Command execution output if successuful:

Detected operating system as Ubuntu/jammy.
Checking for curl...
Detected curl...
Checking for gpg...
Detected gpg...
Running apt-get update... done.
Installing apt-transport-https... done.
Installing /etc/apt/sources.list.d/rabbitmq_rabbitmq-server.list...done.
Importing packagecloud gpg key... done.
Running apt-get update... done.

The repository is setup! You can now install packages.

Step 3: Install RabbitMQ Server Ubuntu 22.04|20.04|18.04

To install RabbitMQ Server Ubuntu 22.04|20.04|18.04, update apt list first:

$ sudo apt update
Hit:1 jammy-security InRelease
Hit:2 jammy InRelease
Hit:3 jammy InRelease
Hit:4 jammy-updates InRelease
Hit:6 jammy-backports InRelease
Hit:5 jammy InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.

Then install rabbitmq-server package:

sudo apt install rabbitmq-server

Hit the key to start the installation.

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
The following NEW packages will be installed:
  rabbitmq-server soca
0 upgraded, 2 newly installed, 0 to remove and 27 not upgraded.
Need to get 12.3 MB of archives.
After this operation, 15.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

After installation, RabbitMQ service is started and enabled to start on boot. To check the status, run:

$ systemctl status rabbitmq-server.service
 rabbitmq-server.service - RabbitMQ broker
     Loaded: loaded (/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-05-12 23:57:22 EAT; 40s ago
   Main PID: 5631 (beam.smp)
      Tasks: 28 (limit: 9460)
     Memory: 95.0M
        CPU: 3.177s
     CGroup: /system.slice/rabbitmq-server.service
             ├─5631 /usr/lib/erlang/erts-12.2.1/bin/beam.smp -W w -MBas ageffcbf -MHas ageffcbf -MBlmbcs 512 -MHlmbcs 512 -MMmcs 30 -P 1048576 -t 5000000 -stbt db -zdbbl 128000 -sbwt none -sbwtdcpu>
             ├─5642 erl_child_setup 32768
             ├─5672 /usr/lib/erlang/erts-12.2.1/bin/epmd -daemon
             ├─5699 inet_gethost 4
             └─5700 inet_gethost 4

Mei 12 23:57:21 ubuntu22 rabbitmq-server[5631]:   Doc guides:
Mei 12 23:57:21 ubuntu22 rabbitmq-server[5631]:   Support:
Mei 12 23:57:21 ubuntu22 rabbitmq-server[5631]:   Tutorials:
Mei 12 23:57:21 ubuntu22 rabbitmq-server[5631]:   Monitoring:
Mei 12 23:57:21 ubuntu22 rabbitmq-server[5631]:   Logs: /var/log/rabbitmq/[email protected]
Mei 12 23:57:21 ubuntu22 rabbitmq-server[5631]:         /var/log/rabbitmq/[email protected]_upgrade.log
Mei 12 23:57:21 ubuntu22 rabbitmq-server[5631]:         
Mei 12 23:57:21 ubuntu22 rabbitmq-server[5631]:   Config file(s): (none)
Mei 12 23:57:22 ubuntu22 rabbitmq-server[5631]:   Starting broker... completed with 0 plugins.
Mei 12 23:57:22 ubuntu22 systemd[1]: Started RabbitMQ broker.

You can confirm if the service is configured to start on boot using the command:

$ systemctl is-enabled rabbitmq-server.service 

If it returns disabled, enable it by running:

sudo systemctl enable rabbitmq-server

Step 4: Enable the RabbitMQ Management Dashboard (Optional)

You can optionally enable the RabbitMQ Management Web dashboard for easy management.

$ sudo rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node [email protected]:
The following plugins have been configured:
Applying plugin configuration to [email protected]
The following plugins have been enabled:

started 3 plugins.

The Web service should be listening on TCP port 15672

$ sudo ss -tunelp | grep 15672
tcp   LISTEN  0       128          *      users:(("beam.smp",pid=9525,fd=71)) uid:111 ino:39934 sk:9 <->

If you have an active UFW firewall, open both ports 5672 and 15672:

sudo ufw allow proto tcp from any to any port 5672,15672

Access it by opening the URL http://[server IP|Hostname]:15672


By default, the guest user exists and can connect only from localhost. You can login with this user locally with the password “guest”

To be able to login on the network, create an admin user like below:

sudo rabbitmqctl add_user admin StrongPassword
sudo rabbitmqctl set_user_tags admin administrator

Login with this admin username and the password assigned.

Step 5: Set RabbitMQ Cluster (Optional)

If you need to achieve high availability and higher throughput, consider configuring RabbitMQ cluster on your Ubuntu 22.04|20.04|18.04 servers by following the guide below:

RabbitMQ User Management Commands

Delete User:

rabbitmqctl delete_user user

Change User Password:

rabbitmqctl change_password user strongpassword

Create new Virtualhost:

rabbitmqctl add_vhost /my_vhost

List available Virtualhosts:

rabbitmqctl list_vhosts

Delete a virtualhost:

rabbitmqctl delete_vhost /myvhost

Grant user permissions for vhost:

rabbitmqctl set_permissions -p /myvhost user ".*" ".*" ".*"

List vhost permissions:

rabbitmqctl list_permissions -p /myvhost

To list user permissions:

rabbitmqctl list_user_permissions user

Delete user permissions:

rabbitmqctl clear_permissions -p /myvhost user

The next article to read is:


Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.