How to Install and Configure RabbitMQ on RHEL 7
RabbitMQ is one of the most widely deployed open-source message brokers in the world. It implements the Advanced Message Queuing Protocol (AMQP) and provides reliable message delivery, flexible routing, and support for multiple messaging patterns including work queues, publish/subscribe, and request/reply. Applications use RabbitMQ to decouple services, process tasks asynchronously, and distribute workloads across multiple consumers. On RHEL 7, installing RabbitMQ requires adding the Erlang runtime repository first, followed by the RabbitMQ repository, since the Erlang version available in the base RHEL 7 repos is often too old. This guide covers the full installation, initial configuration, management plugin setup, creating virtual hosts and users, configuring firewall rules, and connecting to the management web interface.
Prerequisites
- RHEL 7 server with root or sudo access
- Active Red Hat subscription or configured yum repositories
- At least 512 MB of free RAM (1 GB or more recommended for production)
- Internet access or access to a package mirror
- SELinux in permissive or enforcing mode (this guide includes SELinux notes)
Step 1: Install Required Dependencies
RabbitMQ requires the Erlang runtime. The version shipped with RHEL 7 base repositories is typically too old, so we will use the dedicated RabbitMQ Erlang repository which provides a compatible, supported version. First, install a few prerequisite packages:
sudo yum install -y curl gnupg socat logrotate
Step 2: Add the Erlang Repository
RabbitMQ maintains a dedicated Erlang repository for RPM-based systems. Create the repo file:
sudo vi /etc/yum.repos.d/rabbitmq-erlang.repo
Add the following content:
[rabbitmq-erlang]
name=rabbitmq-erlang
baseurl=https://packagecloud.io/rabbitmq/erlang/el/7/$basearch
repo_gpgcheck=1
gpgcheck=1
enabled=1
gpgkey=https://packagecloud.io/rabbitmq/erlang/gpgkey
https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
Step 3: Add the RabbitMQ Repository
Create the RabbitMQ server repository file:
sudo vi /etc/yum.repos.d/rabbitmq-server.repo
Add the following content:
[rabbitmq-server]
name=rabbitmq-server
baseurl=https://packagecloud.io/rabbitmq/rabbitmq-server/el/7/$basearch
repo_gpgcheck=1
gpgcheck=1
enabled=1
gpgkey=https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
Step 4: Install Erlang and RabbitMQ
With both repositories configured, install Erlang first, then RabbitMQ:
sudo yum install -y erlang
Verify Erlang is installed correctly:
erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell
This should print the OTP release number (e.g., 25). Now install RabbitMQ:
sudo yum install -y rabbitmq-server
Step 5: Enable and Start RabbitMQ
Enable the RabbitMQ service to start at boot and then start it:
sudo systemctl enable rabbitmq-server
sudo systemctl start rabbitmq-server
sudo systemctl status rabbitmq-server
The output should show active (running). RabbitMQ starts an Erlang node named rabbit@hostname where hostname is your server’s short hostname. Verify the node is running with the RabbitMQ CLI:
sudo rabbitmqctl status
This prints detailed information about the running node including Erlang version, memory usage, disk alarms, and loaded applications.
Step 6: Enable the Management Plugin
RabbitMQ ships with a powerful web-based management interface that is implemented as a plugin. Enable it with:
sudo rabbitmq-plugins enable rabbitmq_management
Output confirms the plugin is enabled:
Enabling plugins on node rabbit@db01:
rabbitmq_management
The following plugins have been configured:
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
Applying plugin configuration to rabbit@db01...
The following plugins have been enabled:
rabbitmq_web_dispatch
rabbitmq_management_agent
rabbitmq_management
started 3 plugins.
The management UI is now listening on port 15672. Restart RabbitMQ to ensure the plugin is fully initialised:
sudo systemctl restart rabbitmq-server
Step 7: Create an Administrator User
RabbitMQ creates a default user named guest with password guest, but this user can only connect from localhost by design. For remote management and application connections, create a dedicated administrator account. Replace adminuser and SecurePassword456! with your chosen credentials:
sudo rabbitmqctl add_user adminuser SecurePassword456!
sudo rabbitmqctl set_user_tags adminuser administrator
Grant the new user full permissions on the default virtual host:
sudo rabbitmqctl set_permissions -p "/" adminuser ".*" ".*" ".*"
Optionally, delete or disable the default guest account if you will be accessing the management UI remotely:
sudo rabbitmqctl delete_user guest
Step 8: Create a Virtual Host and Application User
Virtual hosts in RabbitMQ provide logical separation between applications. Create a dedicated virtual host for your application and a separate user with restricted permissions:
sudo rabbitmqctl add_vhost /myapp
sudo rabbitmqctl add_user appuser AppPassword789!
sudo rabbitmqctl set_permissions -p "/myapp" appuser ".*" ".*" ".*"
The three ".*" patterns represent configure, write, and read permissions. These grant full access within the /myapp virtual host only. The appuser account cannot access other virtual hosts, providing isolation between applications sharing the same RabbitMQ instance.
Verify the configuration:
sudo rabbitmqctl list_vhosts
sudo rabbitmqctl list_users
sudo rabbitmqctl list_permissions -p /myapp
Step 9: Configure the Firewall
RabbitMQ uses several ports. Open only those required for your deployment:
- 5672 — AMQP protocol port used by application clients
- 15672 — Management UI HTTP port
- 25672 — Erlang distribution port used for clustering (keep private)
- 4369 — EPMD (Erlang Port Mapper Daemon) used for node discovery in clusters
Open the AMQP port for application servers on your internal network:
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.0/24" port protocol="tcp" port="5672" accept'
Open the management UI port for administrative access from a trusted IP:
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.5/32" port protocol="tcp" port="15672" accept'
Apply the changes:
sudo firewall-cmd --reload
sudo firewall-cmd --list-all
Do not open port 25672 or 4369 to the public internet. These ports should only be accessible between RabbitMQ cluster nodes on a private network.
Step 10: Access the Management UI
Open a web browser and navigate to:
http://your-server-ip:15672
Log in with the administrator credentials you created in Step 7. The management UI provides:
- Overview — Global statistics including message rates, connections, channels, and queues
- Connections — Active client connections with their state and protocol version
- Channels — Open channels and per-channel message rates
- Exchanges — All configured exchanges with their type (direct, topic, fanout, headers)
- Queues — All queues with depth, consumer count, and message rates
- Admin — User management, virtual host management, and policy configuration
Step 11: Test with a Simple Queue (Command Line)
Verify RabbitMQ is working correctly by creating a test queue, publishing a message, and consuming it using the management HTTP API:
# Declare a test queue
curl -u adminuser:SecurePassword456!
-X PUT
-H "Content-Type: application/json"
-d '{"durable":false}'
http://localhost:15672/api/queues/%2F/test_queue
# Publish a test message
curl -u adminuser:SecurePassword456!
-X POST
-H "Content-Type: application/json"
-d '{"properties":{},"routing_key":"test_queue","payload":"Hello RabbitMQ","payload_encoding":"string"}'
http://localhost:15672/api/exchanges/%2F/amq.default/publish
# Get (consume) the message
curl -u adminuser:SecurePassword456!
-X POST
-H "Content-Type: application/json"
-d '{"count":1,"ackmode":"ack_requeue_false","encoding":"auto"}'
http://localhost:15672/api/queues/%2F/test_queue/get
Conclusion
You have successfully installed and configured RabbitMQ on RHEL 7, starting from adding the correct Erlang and RabbitMQ repositories, through to configuring virtual hosts, users, permissions, and firewall rules. The management plugin gives you a powerful browser-based interface for monitoring queue depths, connection states, and message throughput in real time. RabbitMQ’s combination of reliability, flexible routing, and strong operational tooling makes it an excellent choice for decoupling microservices, managing background job queues, and building event-driven architectures. With this foundation in place, your next steps could include configuring TLS for encrypted AMQP connections, setting up a high-availability cluster across multiple nodes, or configuring dead-letter exchanges to handle failed message processing.