In this tutorial, we'll explain how to install and configure RabbitMQ on Ubuntu 24.04 server. Enable RabbitMQ management console.
RabbitMQ is a widely used open-source message broker software that facilitates communication between different components of a distributed system. It acts as an intermediary for messaging between applications, allowing them to send and receive messages reliably and asynchronously.
Prerequisites
- A server running Ubuntu 24.04.
- A user with sudo privileges.
- Basic knowledge of command-line operations.
Install and Configure RabbitMQ on Ubuntu
Step 1: Update the System
First, ensure your system is updated:
sudo apt update
sudo apt upgrade -y
Step 2: Install Erlang
Before you begin, make sure you have the necessary dependencies installed. Open a terminal and run the following commands:
sudo apt install -y build-essential autoconf libncurses5-dev libssl-dev
Visit the Erlang/OTP official download page to find the version you want. Download the source code tarball using wget or curl.
For example, to download Erlang/OTP 27.0
:
wget https://github.com/erlang/otp/releases/download/OTP-27.0.1/otp_src_27.0.1.tar.gz
Extract the downloaded tarball:
tar -xzvf otp_src_27.0.1.tar.gz
cd otp_src_27.0.1
Run the configuration script to prepare the source code for building. You can specify options here if needed.
./configure
Note: If you need to install Erlang in a specific directory, use:
./configure --prefix=/your/install/path
Build Erlang, compile the source code:
make
Note: This process may take some time, depending on your system’s performance.
Once the build is complete, install Erlang:
sudo make install
Note: If you specified a custom installation path, you might need to adjust your PATH
environment variable to include the Erlang binaries.
Check the installed version to ensure everything is set up correctly:
erl -version
You should see the version of Erlang you installed.
Step 3: Install RabbitMQ Server
Now, install RabbitMQ server:
sudo apt install -y rabbitmq-server
Check the status of RabbitMQ to ensure it is running:
sudo systemctl status rabbitmq-server
You should see an output indicating that RabbitMQ is active and running.
Step 4: Enable RabbitMQ Management Console
RabbitMQ comes with a built-in management plugin that can be enabled to manage the server via a web interface:
sudo rabbitmq-plugins enable rabbitmq_management
Step 5: Create an Admin User (Optional)
For better security, create an admin user and delete the default guest user:
sudo rabbitmqctl add_user admin strongpassword
sudo rabbitmqctl set_user_tags admin administrator
sudo rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
Delete the guest user:
sudo rabbitmqctl delete_user guest
Step 6: Configure RabbitMQ for Remote Access (Optional)
By default, RabbitMQ only allows localhost
connections. To enable remote connections, modify the RabbitMQ configuration file.
Edit the rabbitmq.conf
file:
sudo nano /etc/rabbitmq/rabbitmq.conf
Add the following lines to allow remote connections:
listeners.tcp.default = 5672
loopback_users.guest = false
management.listener.port = 15672
management.listener.ip = 0.0.0.0
Save and close the file, then restart RabbitMQ:
sudo systemctl restart rabbitmq-server
Step 7: Secure RabbitMQ with Firewall (Optional)
If your server is behind a firewall, open the necessary ports:
sudo ufw allow 5672/tcp
sudo ufw allow 15672/tcp
sudo ufw reload
Conclusion
You have successfully seen how install and configure RabbitMQ on Ubuntu 24.04 server. You can now use RabbitMQ for your messaging needs, and manage it via the web interface at http://<your_server_ip>:15672
.
Feel free to reach out if you need further assistance or have any questions!