RabbitMQ is a widely-used open-source message broker that enables applications to communicate asynchronously by sending messages between producers and consumers. It’s ideal for building scalable, distributed systems. In this guide, we will walk you through how to install RabbitMQ on Ubuntu 24.04 Server, perfect for VPS servers hosting applications that require reliable messaging systems.

Step 1: Update Your System

Before installing RabbitMQ, it's important to ensure your server is up to date. Run the following command to update your package list and upgrade any outdated packages:

sudo apt update && sudo apt upgrade -y

Step 2: Install Erlang

RabbitMQ relies on Erlang, so the first step is to install the Erlang package. Add the necessary Erlang repository to your server by running the following commands:


sudo apt install -y curl gnupg apt-transport-https
curl -fsSL https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | sudo apt-key add -
echo "deb https://packages.erlang-solutions.com/ubuntu focal contrib" | sudo tee /etc/apt/sources.list.d/erlang.list
        

Once the repository is added, update your package list and install Erlang:

sudo apt update
sudo apt install erlang -y

Step 3: Install RabbitMQ

Next, install RabbitMQ by adding its official repository. Run the following commands to add the RabbitMQ repository to your system:


echo "deb https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/deb/ubuntu focal main" | sudo tee /etc/apt/sources.list.d/rabbitmq.list
curl -fsSL https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.83FBA17561E8805E2CF68F50C3D310BA61E928D4.key | sudo apt-key add -
        

After adding the repository, update the package list and install RabbitMQ:

sudo apt update
sudo apt install rabbitmq-server -y

Step 4: Start and Enable RabbitMQ

Once RabbitMQ is installed, start the service and enable it to start automatically on boot:


sudo systemctl start rabbitmq-server
sudo systemctl enable rabbitmq-server
        

To verify that RabbitMQ is running, use the following command:

sudo systemctl status rabbitmq-server

Step 5: Enable the RabbitMQ Management Console

RabbitMQ comes with a management console that provides a web-based interface for monitoring and managing your RabbitMQ server. To enable it, run the following command:

sudo rabbitmq-plugins enable rabbitmq_management

The management interface is now available at http://your_server_ip:15672. By default, RabbitMQ uses the default credentials (guest/guest), but you should create a new user for better security.

Step 6: Create an Administrative User

To secure your RabbitMQ installation, create a new user with administrative privileges. Replace your_username and your_password with your desired username and password:


sudo rabbitmqctl add_user your_username your_password
sudo rabbitmqctl set_user_tags your_username administrator
sudo rabbitmqctl set_permissions -p / your_username ".*" ".*" ".*"
        

You can now log into the management console with your new administrative credentials at http://your_server_ip:15672.

Step 7: Configure Firewall (Optional)

If you are running a firewall on your server, ensure that RabbitMQ's default ports (5672 for messaging and 15672 for the management console) are open. Use the following commands to allow RabbitMQ traffic through UFW:


sudo ufw allow 5672/tcp
sudo ufw allow 15672/tcp
sudo ufw reload
        

Step 8: Managing RabbitMQ

RabbitMQ provides several commands for managing your server. Below are some of the commonly used commands:

  • sudo rabbitmqctl list_users – Lists all users.
  • sudo rabbitmqctl delete_user your_username – Deletes a user.
  • sudo rabbitmqctl stop – Stops RabbitMQ.
  • sudo rabbitmqctl start_app – Starts the RabbitMQ application.

Running RabbitMQ on a VPS Server

Running RabbitMQ on a VPS server provides an efficient and scalable solution for message brokering. Whether you're handling microservices or distributed applications, RabbitMQ's lightweight footprint and reliable messaging architecture make it an ideal choice for VPS-hosted applications. With the management console, you can easily monitor queues, exchanges, and message activity on your server.

Looking for a Reliable VPS Solution?

If you're looking for a powerful and scalable VPS server to run RabbitMQ, consider using WindowsVPS. With WindowsVPS, you get high-performance VPS hosting that’s ideal for deploying RabbitMQ and other demanding applications.

War diese Antwort hilfreich? 0 Benutzer fanden dies hilfreich (0 Stimmen)