RabbitMQ is a robust open-source message broker that implements the AMQP protocol, enabling asynchronous communication between application components. It is widely used for task queuing, event streaming, and decoupling microservices. On RHEL 8, RabbitMQ requires a compatible version of Erlang that is best installed from the official RabbitMQ Cloudsmith repository rather than the default RHEL packages. In this tutorial you will install Erlang and RabbitMQ, enable the management web UI, create users and virtual hosts, open the necessary firewall ports, and test message publishing and consuming.

Prerequisites

  • RHEL 8 server with at least 2 GB RAM (4 GB recommended for production)
  • Root or sudo access
  • Active internet connection to reach Cloudsmith package repositories
  • firewalld running

Step 1 — Add the RabbitMQ Cloudsmith Repositories

RabbitMQ provides curated repos for Erlang and RabbitMQ itself that are tested together. Using these avoids version mismatch issues common with distribution packages:

sudo dnf install -y dnf-plugins-core

# Add Erlang repo from Cloudsmith (maintained by RabbitMQ team)
curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | sudo bash

# Add RabbitMQ repo
curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | sudo bash

Step 2 — Install Erlang and RabbitMQ

Install Erlang first, then RabbitMQ. Pinning a compatible Erlang version prevents future upgrades from breaking the broker:

sudo dnf install -y erlang
sudo dnf install -y rabbitmq-server

Enable and start the service:

sudo systemctl enable --now rabbitmq-server
sudo systemctl status rabbitmq-server

Step 3 — Enable the Management Plugin

The RabbitMQ management plugin provides a browser-based UI and a REST API on port 15672:

sudo rabbitmq-plugins enable rabbitmq_management
sudo systemctl restart rabbitmq-server

Install the rabbitmqadmin command-line tool from the management API:

curl -s http://localhost:15672/cli/rabbitmqadmin -o /usr/local/bin/rabbitmqadmin
chmod +x /usr/local/bin/rabbitmqadmin

Step 4 — Create Admin User, Virtual Host, and Permissions

The default guest account is restricted to localhost only. Create a named administrator account and a dedicated virtual host for your application:

# Create an administrator user
sudo rabbitmqctl add_user adminuser 'StrongRabbitPass1!'
sudo rabbitmqctl set_user_tags adminuser administrator

# Remove the default guest account
sudo rabbitmqctl delete_user guest

# Create an application virtual host
sudo rabbitmqctl add_vhost /myapp

# Grant the admin user full permissions on the vhost
sudo rabbitmqctl set_permissions -p /myapp adminuser ".*" ".*" ".*"

# List users and vhosts to confirm
sudo rabbitmqctl list_users
sudo rabbitmqctl list_vhosts

Step 5 — Open Firewall Ports

RabbitMQ uses port 5672 for AMQP client connections and port 15672 for the management UI. Restrict management access to trusted IPs:

# Open AMQP port for application servers
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.0/24" port port="5672" protocol="tcp" accept'

# Open management UI for admin workstations only
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.10/32" port port="15672" protocol="tcp" accept'

sudo firewall-cmd --reload
sudo firewall-cmd --list-rich-rules

Step 6 — Publish and Consume a Test Message

Use rabbitmqadmin to create a queue, publish a message, and consume it from the command line:

# Declare a durable queue on the application vhost
rabbitmqadmin -u adminuser -p 'StrongRabbitPass1!' -V /myapp 
  declare queue name=test-queue durable=true

# Publish a test message
rabbitmqadmin -u adminuser -p 'StrongRabbitPass1!' -V /myapp 
  publish exchange=amq.default routing_key=test-queue 
  payload="Hello from RHEL 8"

# Consume (get) the message
rabbitmqadmin -u adminuser -p 'StrongRabbitPass1!' -V /myapp 
  get queue=test-queue ackmode=ack_requeue_false

The consume command should print the payload Hello from RHEL 8 along with message metadata, confirming the broker is fully operational.

Conclusion

You have installed Erlang and RabbitMQ from the official Cloudsmith repositories on RHEL 8, enabled the management plugin and REST API, created a secure admin user and application virtual host, restricted firewall access to AMQP and management ports, and verified message flow end-to-end. RabbitMQ is now ready to handle production workloads for task queues and event-driven architectures.

Next steps: Configuring RabbitMQ Clustering on RHEL 8, Setting Up RabbitMQ TLS/SSL Encryption, and Monitoring RabbitMQ with Prometheus.