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:
- Ubuntu 24.04: Ensure you have Ubuntu 24.04 installed and running on your system.
- User with sudo privileges: You will need a user with sudo access to install software.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- Start the RabbitMQ service:
sudo systemctl start rabbitmq-server
This command starts the RabbitMQ service immediately.
- Enable the RabbitMQ service:
sudo systemctl enable rabbitmq-server
This command ensures RabbitMQ starts automatically when your system boots.
- 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.
- Enable the RabbitMQ management plugin:
sudo rabbitmq-plugins enable rabbitmq_management
This command enables the management dashboard plugin.
- 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.
- Add a new RabbitMQ user:
sudo rabbitmqctl add_user your_username your_password
Replace your_username
and your_password
with your preferred credentials.
- Set the user’s permissions:
sudo rabbitmqctl set_permissions -p / your_username ".*" ".*" ".*"
This command grants the user full access to the RabbitMQ instance.
- Set a new user as an administrator:
sudo rabbitmqctl set_user_tags your_username administrator
This command assigns administrative rights to the new user.
- 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:
- List all users:
sudo rabbitmqctl list_users
This command lists all the users in your RabbitMQ server.
- List all queues:
sudo rabbitmqctl list_queues
This command displays all the queues available in RabbitMQ.
- Stop the RabbitMQ server:
sudo systemctl stop rabbitmq-server
Use this command to stop RabbitMQ when necessary.
- 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.
- Stop the RabbitMQ service:
sudo systemctl stop rabbitmq-server
This command stops the RabbitMQ service.
- Uninstall RabbitMQ:
sudo apt remove --purge rabbitmq-server -y
This command completely removes RabbitMQ from your system.
- Remove Erlang (optional):
sudo apt remove --purge erlang -y
If you no longer need Erlang, this command will remove it from your system.
- 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.
Thank you for reading the article! If you found the information useful, you can donate using the buttons below:
Donate ☕️ with PayPalDonate 💳 with Revolut