How to Install RabbitMQ on Ubuntu 24.04: A Step-by-Step Guide

 How to Install RabbitMQ on Ubuntu 24.04: A Step-by-Step Guide

RaRabbitMQ is a powerful open-source message broker that enables applications to communicate with each other. It is used widely in microservices architectures, distributed systems, and various real-time applications. Installing RabbitMQ on Ubuntu 24.04 is straightforward, but it’s essential to follow the steps carefully to ensure a successful setup. This guide will walk you through the process, making it easy even for those new to Ubuntu or RabbitMQ.

Prerequisites

Before you start, make sure your system meets the following requirements:

  1. Ubuntu 24.04: Ensure you have Ubuntu 24.04 installed and running on your system.
  2. User with sudo privileges: You will need a user with sudo access to install software.
  3. Internet connection: A stable internet connection is necessary to download RabbitMQ and its dependencies.

Step 1: Update Your System

First, update the package list and upgrade the system to ensure you have the latest software versions. This step is crucial for system stability.

sudo apt update sudo apt upgrade -y 

These commands update the package list and install any available updates.

Step 2: Install Erlang

RabbitMQ is built on the Erlang programming language, so Erlang must be installed first. To install Erlang, you need to add the Erlang Solutions repository.

  1. Import the GPG key:
sudo apt install curl -y curl -fsSL https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | sudo tee /etc/apt/trusted.gpg.d/erlang_solutions.asc 

This command imports the GPG key needed for package verification.

  1. Add the Erlang Solutions repository:
echo "deb https://packages.erlang-solutions.com/ubuntu focal contrib" | sudo tee /etc/apt/sources.list.d/erlang.list 

This command adds the Erlang Solutions repository to your system.

  1. Update the package list and install Erlang:
sudo apt update sudo apt install erlang -y 

This command installs Erlang, a necessary dependency for RabbitMQ.

Step 3: Install RabbitMQ Server

After installing Erlang, you can now install RabbitMQ. RabbitMQ also provides a repository that you need to add to your system.

  1. Import the GPG key for RabbitMQ:
curl -fsSL https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey | sudo tee /etc/apt/trusted.gpg.d/rabbitmq.asc 

This command imports the GPG key for RabbitMQ, ensuring secure package downloads.

  1. Add the RabbitMQ repository:
echo "deb https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu focal main" | sudo tee /etc/apt/sources.list.d/rabbitmq.list 

This command adds the RabbitMQ repository to your system.

  1. Update the package list and install RabbitMQ:
sudo apt update sudo apt install rabbitmq-server -y 

This command installs the RabbitMQ server on your Ubuntu system.

Step 4: Start and Enable RabbitMQ

Once RabbitMQ is installed, you need to start the service and enable it to run on boot.

  1. Start the RabbitMQ service:
sudo systemctl start rabbitmq-server 

This command starts the RabbitMQ service immediately.

  1. Enable the RabbitMQ service:
sudo systemctl enable rabbitmq-server 

This command ensures RabbitMQ starts automatically when your system boots.

  1. Check the status of RabbitMQ:
sudo systemctl status rabbitmq-server 

This command allows you to verify if RabbitMQ is running correctly. You should see a status indicating that it is active and running.

Step 5: Enable RabbitMQ Management Dashboard

RabbitMQ provides a web-based management interface that is very useful for monitoring and managing your RabbitMQ server. By default, this plugin is not enabled.

  1. Enable the RabbitMQ management plugin:
sudo rabbitmq-plugins enable rabbitmq_management 

This command enables the management dashboard plugin.

  1. Access the RabbitMQ management interface:

After enabling the plugin, you can access the interface via your web browser. The default URL is:

arduinohttp://localhost:15672/ 

Use the default credentials to log in:

  • Username: guest
  • Password: guest

For security reasons, it’s recommended to change these credentials in a production environment.

Step 6: Configure RabbitMQ (Optional but Recommended)

Depending on your use case, you might want to perform some basic configurations.

  1. Add a new RabbitMQ user:
sudo rabbitmqctl add_user your_username your_password 

Replace your_username and your_password with your preferred credentials.

  1. Set the user’s permissions:
sudo rabbitmqctl set_permissions -p / your_username ".*" ".*" ".*" 

This command grants the user full access to the RabbitMQ instance.

  1. Set a new user as an administrator:
sudo rabbitmqctl set_user_tags your_username administrator 

This command assigns administrative rights to the new user.

  1. Delete the default guest user:
sudo rabbitmqctl delete_user guest 

This step is essential for securing your RabbitMQ server in a production environment.

Step 7: Managing RabbitMQ from the Command Line

In addition to the web-based management dashboard, you can also manage RabbitMQ from the command line. Here are a few useful commands:

  1. List all users:
sudo rabbitmqctl list_users 

This command lists all the users in your RabbitMQ server.

  1. List all queues:
sudo rabbitmqctl list_queues 

This command displays all the queues available in RabbitMQ.

  1. Stop the RabbitMQ server:
sudo systemctl stop rabbitmq-server 

Use this command to stop RabbitMQ when necessary.

  1. Restart the RabbitMQ server:
sudo systemctl restart rabbitmq-server 

This command restarts RabbitMQ, which can be useful after making configuration changes.

Step 8: Uninstall RabbitMQ (Optional)

If you need to remove RabbitMQ from your system, follow these steps.

  1. Stop the RabbitMQ service:
sudo systemctl stop rabbitmq-server 

This command stops the RabbitMQ service.

  1. Uninstall RabbitMQ:
sudo apt remove --purge rabbitmq-server -y 

This command completely removes RabbitMQ from your system.

  1. Remove Erlang (optional):
sudo apt remove --purge erlang -y 

If you no longer need Erlang, this command will remove it from your system.

  1. Clean up:
sudo apt autoremove -y sudo apt autoclean 

These commands clean up any leftover dependencies and packages.

Conclusion

Installing RabbitMQ on Ubuntu 24.04 is a straightforward process if you follow these steps carefully. From updating your system, installing Erlang, to finally setting up RabbitMQ, each step is crucial. The web-based management interface adds a layer of convenience, allowing you to monitor and manage RabbitMQ effortlessly. Whether you’re setting up a test environment or a production server, these steps ensure that RabbitMQ is up and running smoothly on your Ubuntu system.

Fedya Serafiev

Fedya Serafiev

Fedya Serafiev owns the website linuxcodelab.eu. He finds satisfaction in helping people solve even the most complex technical problems. His current goal is to write easy-to-follow articles so that such problems do not arise at all.

Thank you for reading the article! If you found the information useful, you can donate using the buttons below: