How to Install RabbitMQ in Linux

Install RabbitMQ Linux

RabbitMQ is a free and open-source messaging system that enables various applications to share data seamlessly. It supports asynchronous messaging, which means one app can send a message without waiting for the other to respond right away. Installing RabbitMQ on Linux ensures messages are reliably delivered and properly routed, even when parts of your system are busy or temporarily offline. It’s widely used in modern software systems to connect microservices, handle background tasks, and manage data flow between services.

In this guide, we’ll show how to install RabbitMQ on a Linux system using the default package repository and Docker.  

Install RabbitMQ in Linux

We will demonstrate the steps for Ubuntu/Debian-based systems. For other Linux distributions, you can install RabbitMQ by using the appropriate package manager for your system.

Step 1: Update System Packages

Run the command below to refresh your system’s software package index and ensure access to the latest versions during installation or upgrades:

sudo apt update

Step 2: Install Erlang 

Now execute this command to install Erlang on your system, which is a required dependency for running RabbitMQ on your system. It ensures that the message broker has the necessary runtime environment to function properly:

sudo apt install erlang -y
install erlang

Step 3: Install Erlang RabbitMQ Server

Finally, you can use this command to install the RabbitMQ server on your system:

sudo apt install rabbitmq-server

It downloads and sets up the RabbitMQ service so you can start using it to handle messaging between applications:

install rabbitmq

Step 4: Enable and Start RabbitMQ

Enable the RabbitMQ service to start automatically every time your system boots:

sudo systemctl enable rabbitmq-server
enable rabbitmq

Once the RabbitMQ service is activated, run the command below to launch the RabbitMQ server:

sudo systemctl start rabbitmq-server
start rabbitmq service

Step 5: Verify RabbitMQ Installation Status

Let’s check the RabbitMQ status to confirm that it’s been installed successfully and is up and running:

sudo systemctl status rabbitmq-server
verify installation

Step 6: Enable the RabbitMQ Management Dashboard 

Use the following command to enable the RabbitMQ management plugin, which provides a user-friendly web interface. This step is optional but recommended

sudo rabbitmq-plugins enable rabbitmq_management
enable rabbitmq dashboard

How to Access and Use RabbitMQ

Once RabbitMQ is set up on your Linux system, you can access it in your browser by specifying the “http://localhost:15672” URL. Provide the default username and password as “guest”, and hit the login button to proceed:

access rabbitmq interface

As a result, you’ll be navigated to the following dashboard. Here, you can monitor and manage queues, connections, users, and system status easily:

use rabbitmq

How to Uninstall RabbitMQ From Linux

To uninstall RabbitMQ completely from your system, first, stop the RabbitMQ service:

sudo systemctl stop rabbitmq-server
stop the RabbitMQ service

Now uninstall RabbitMQ and Erlang from your system using the apt remove command:

sudo apt remove --purge rabbitmq-server erlang -y
remove the RabbitMQ service

Remove residual dependencies as well with the following command:

sudo apt autoremove -y
remove dependent dependencies

Finally, delete RabbitMQ and Erlang configuration, cache, and log files using the following commands:

sudo rm -rf /etc/rabbitmq && sudo rm -rf /var/lib/rabbitmq && sudo rm -rf /var/log/rabbitmq
delete rabbitmq related files

Install RabbitMQ on Linux Using Docker

Installing RabbitMQ using Docker is one of the simplest and fastest ways to get it up and running. It lets you pull a preconfigured image and start the server without dealing with manual dependencies or system configurations. Here are the steps you need to follow to install RabbitMQ using Docker:

Step 1: Pull RabbitMQ Docker Image

You can use this command to download the official RabbitMQ Docker image with the management dashboard included:

sudo docker pull rabbitmq:3-management

This command pulls the image from Docker Hub so you can run RabbitMQ in a container without installing it directly on your system:

pull rabbitmq image

Step 2: Install RabbitMQ on Linux using Docker

Now, use this command to run RabbitMQ in a Docker container with the management interface enabled. It will be accessible on your local system through the default ports:

sudo docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management
run rabbitmq container

Step 3: Access RabbitMQ Management Interface

After this, you can access the RabbitMQ management dashboard by visiting the http://localhost:15672 URL in your web browser:

dashboard rabbitmq management

Uninstall RabbitMQ From Docker

If RabbitMQ was set up with Docker, begin by verifying its running status with this command:

sudo docker ps

Then stop and remove the container using the docker stop and docker run commands: 

sudo docker stop rabbitmq && sudo docker rm rabbitmq
stop and remove rabbitmq

Remove the RabbitMQ Docker Image using the following command:

sudo docker rmi rabbitmq:3-management
remove rabbitmq docker image

This sums up the installation process of RabbitMQ on Linux.

Conclusion

RabbitMQ helps you manage communication between services and applications efficiently. In this guide, we installed it on a Linux system using two different methods: through the APT package manager and with Docker. Docker gives you the fastest and simplest way to get RabbitMQ up and running. You can also enable the management dashboard to make it easier to monitor and control your messaging setup. 

Installing RabbitMQ on a Linux system is straightforward with the right setup. Ultahost’s affordable VPS hosting plans offer full root access, NVMe SSD storage, and a secure platform. This makes it easy to deploy RabbitMQ across various Linux distributions with speed, stability, and full control.

FAQ

What is RabbitMQ, and why is it used?
Do I need Erlang to install RabbitMQ?
What are the default credentials for the RabbitMQ management dashboard?
How can I check if RabbitMQ is running after installation?
How do I completely uninstall RabbitMQ from my Linux system?
What ports does RabbitMQ use by default?
Can I access RabbitMQ from another device on the network?

Related Post

What is the Load Average in Linux? How to Che...

The Load Average which is also known as system load is ...

How to Set or Change User Agent with curl

Curl is a valuable tool for web development and testing...

Exploring chsh Command in Linux with Examples

The chsh command a utility commonly found in Linux dist...

Exploring Sed Command in Linux

The sed command stands for stream editor is a powerful ...

Exploring Linux cut Command with Examples

The Linux cut command is a powerful utility that allows...

How to Set Up and Use Private Docker Registry

Setting up a private Docker registry can significantly ...

Leave a Comment