Before doing any kind of task first we have to install RabbitMQ.

RabbitMQ Installation

Here is a step-by-step guide on how to install RabbitMQ:

  1. As there are so many commands to run, I am creating a shell script to ease this process. To create a shell script open the terminal and run this command.
touch rabit.sh;nano rabbit.sh

Untitled

it will create a file named rabbit.sh and open it on the nano text editor.

  1. Paste the following code on the rabbit.sh. As my system is **Debian-**based and the version name is Bookworm, I am changing some things while adding the source list directory. You can find what should you change based on your distro on the official RabbitMQ documentation.
#!/bin/sh

sudo apt-get install curl gnupg apt-transport-https -y

## Team RabbitMQ's main signing key
curl -1sLf "<https://keys.openpgp.org/vks/v1/by-fingerprint/0A9AF2115F4687BD29803A206B73A36E6026DFCA>" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/com.rabbitmq.team.gpg > /dev/null
## Community mirror of Cloudsmith: modern Erlang repository
curl -1sLf <https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key> | sudo gpg --dearmor | sudo tee /usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg > /dev/null
## Community mirror of Cloudsmith: RabbitMQ repository
curl -1sLf <https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-server.9F4587F226208342.key> | sudo gpg --dearmor | sudo tee /usr/share/keyrings/rabbitmq.9F4587F226208342.gpg > /dev/null

sudo tee /etc/apt/sources.list.d/rabbitmq.list <<EOF
## Provides modern Erlang/OTP releases from a Cloudsmith mirror
##
deb [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] <https://ppa1.novemberain.com/rabbitmq/rabbitmq-erlang/deb/debian> bullseye main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] <https://ppa1.novemberain.com/rabbitmq/rabbitmq-erlang/deb/debian> bullseye main

deb [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] <https://ppa2.novemberain.com/rabbitmq/rabbitmq-erlang/deb/debian> bullseye main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] <https://ppa2.novemberain.com/rabbitmq/rabbitmq-erlang/deb/debian> bullseye main

## Provides RabbitMQ from a Cloudsmith mirror
##
deb [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] <https://ppa1.novemberain.com/rabbitmq/rabbitmq-server/deb/debian> bullseye main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] <https://ppa1.novemberain.com/rabbitmq/rabbitmq-server/deb/debian> bullseye main

# another mirror for redundancy
deb [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] <https://ppa2.novemberain.com/rabbitmq/rabbitmq-server/deb/debian> bullseye main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] <https://ppa2.novemberain.com/rabbitmq/rabbitmq-server/deb/debian> bullseye main
EOF

sudo apt-get update -y

## Install Erlang packages
sudo apt-get install -y erlang-base \\
                        erlang-asn1 erlang-crypto erlang-eldap erlang-ftp erlang-inets \\
                        erlang-mnesia erlang-os-mon erlang-parsetools erlang-public-key \\
                        erlang-runtime-tools erlang-snmp erlang-ssl \\
                        erlang-syntax-tools erlang-tftp erlang-tools erlang-xmerl

## Install rabbitmq-server and its dependencies
sudo apt-get install rabbitmq-server -y --fix-missing
  1. After pasting this on rabbit.sh file close the editor and give it execute permission.
chmod +x rabbit.sh
  1. Then run the script using this command. It will start installing all the necessary items to run RabbitMQ.
./rabbit.sh

Untitled

Running RabbitMQ

  1. Paste the following command to run the RabbitMQ server.
systemctl start rabbitmq-server
  1. Check if it is working properly by running the following command.