Install Apache ActiveMQ on Ubuntu 20.04
原文链接:https://www.vultr.com/docs/install-apache-activemq-on-ubuntu-20-04/
Introduction
A message broker enables applications to communicate with each other to share information. Apache ActiveMQ is a popular open-source, multi-protocol, Java message broker. It supports industry-standard protocols such as AMQP (Advanced Message Queuing Protocol) to integrate multi-platform applications, STOMP (Simple Text Orientated Messaging Protocol) for exchanging messages between web applications over websockets, and MQTT (Message Queuing Telemetry Transport) to manage IoT devices. In this article, you will learn how to install Apache ActiveMQ on Ubuntu 20.04 server.
Prerequisites
- Deploy a fully updated Vultr Ubuntu 20.04 Server.
- Create a non-root user with sudo access.
1. Install Java
-
Update the system.
$ sudo apt update
-
Apache ActiveMQ requires Java to run. Install Java.
$ sudo apt install openjdk-11-jre -y
-
Verify the Java installation.
$ java -version
2. Install and Configure Apache ActiveMQ
-
Download ActiveMQ from the Apache. To find the latest version of this software, you can visit the download page.
$ wget http://archive.apache.org/dist/activemq/5.16.3/apache-activemq-5.16.3-bin.tar.gz
-
Extract the downloaded file.
$ sudo tar -xvzf apache-activemq-5.16.3-bin.tar.gz
-
Create a directory named
/opt/activemq
.$ sudo mkdir /opt/activemq
-
Move the extracted files to the
/opt/activemq
directory.$ sudo mv apache-activemq-5.16.3/* /opt/activemq
-
Create a group account
activemq
to run Apache ActiveMQ.$ sudo addgroup --quiet --system activemq
-
Create a user for the group.
$ sudo adduser --quiet --system --ingroup activemq --no-create-home --disabled-password activemq
-
Change the permissions of the
/opt/activemq
directory.$ sudo chown -R activemq:activemq /opt/activemq
-
Create an ActiveMQ systemd service file to control the Apache ActiveMQ service.
$ sudo nano /etc/systemd/system/activemq.service
-
Add the below code into the file. Save and close the file.
[Unit] Description=Apache ActiveMQ After=network.target [Service] Type=forking User=activemq Group=activemq ExecStart=/opt/activemq/bin/activemq start ExecStop=/opt/activemq/bin/activemq stop [Install] WantedBy=multi-user.target
-
Edit the
jetty.xml
configuration file to change the host.$ sudo nano /opt/activemq/conf/jetty.xml
-
Find the line below:
<property name="host" value="127.0.0.1"/>
Change it to:
<property name="host" value="0.0.0.0"/>
-
Save and close the file.
-
Reload the system daemon.
$ sudo systemctl daemon-reload
-
Start the Apache ActiveMQ service.
$ sudo systemctl start activemq
-
Enable the Apache ActiveMQ service to run at system startup.
$ sudo systemctl enable activemq
-
Verify the status of the service.
$ sudo systemctl status activemq
-
Restart ActiveMQ service.
$ sudo systemctl restart activemq
3. Access Apache ActiveMQ Web Interface
Open your web browser and access the Apache ActiveMQ web UI using the URL http://YourServerIP:8161/admin/
. For example:
http://192.0.2.10:8161/admin/
Conclusion
You have successfully installed Apache ActiveMQ on your Ubuntu server. Use the default credentials admin as your username and admin as your password to log in. You can now configure Apache ActiveMQ via the dashboard.