How to Install Apache ActiveMQ on CentOS 7

Apache ActiveMQ is a free and open source message broker and integration pattern server. It supports many cross language clients and protocols from JAVA, C++, C, Python, Perl, PHP etc. It provides many features such as Message Groups, Virtual Destinations, Wildcards and Composite Destinations etc. It can be easily integrated to spring applications.

In this tutorial, we will install Apache ActiveMQ on CentOS 7 server.


  • Minimal CentOS 7 server
  • Root privileges. This guide is written as the root user, if you are logged in as sudo user, run sudo -i.

Update Base System

Before installing any package it is recommended that you update the packages and repository using the following command.

yum -y update

Once your system is updated, proceed further to install JAVA.

Install JAVA

ActiveMQ supports both OpenJDK and Oracle JAVA, in this tutorial we will install the latest version of Oracle Java into the server. Run the following command to download the RPM package.

wget --no-cookies --no-check-certificate --header "Cookie:oraclelicense=accept-securebackup-cookie" ""

If you do not have wget installed, you can run the yum -y install wget to install wget. Now install the downloaded RPM using the following command.

yum -y localinstall jdk-8u131-linux-x64.rpm

You can now check the Java version using the following command.

java -version

You will get the following output.

[[email protected] ~]# java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

You will also need to check if JAVA_HOME environment variable is set. Run the following command for same.


If you get a null or blank output, you will need to manually set the JAVA_HOME variable. Edit the .bash_profile file using your favourite editor. In this tutorial, we will use nano editor. Run the following command to edit .bash_profile using nano.

nano ~/.bash_profile

Now add the following lines at the at the end of the file.

export JAVA_HOME=/usr/java/jdk1.8.0_131/
export JRE_HOME=/usr/java/jdk1.8.0_131/jre

Now source the file using the following command.

source ~/.bash_profile

Now you can run the echo $JAVA_HOME command again to check if the environment variable is set or not.

[[email protected] ~]# echo $JAVA_HOME 

Install ActiveMQ

ActiveMQ provides binaries for Unix systems which are precompiled and can be used directly. The only required dependency was to install JAVA into the system. As we have installed JAVA we can proceed further to download ActiveMQ.


If you do not have wget installed, you can run yum -y install wget. You can always find the link to the latest version on ActiveMQ download page.

Extract the archive using the following command.

tar -zxvf apache-activemq-*-bin.tar.gz -C /var

Change the name of the ActiveMQ directory for the sake of simplicity by running.

mv /var/apache-activemq-*/ /var/activemq/

ActiveMQ is now installed on your system.

Starting ActiveMQ

Change your current directory to ActiveMQ installation directory.

cd /var/activemq

You can immediately start ActiveMQ as a foreground process by running the following command.

./bin/activemq console

To start ActiveMQ as background process, run:

./bin/activemq start

You should get the following output if started successfully.

[[email protected] activemq]# ./bin/activemq start
INFO: Loading '/var/activemq//bin/env'
INFO: Using java '/usr/java/jdk1.8.0_131//bin/java'
INFO: Starting - inspect logfiles specified in and to get details
INFO: pidfile created : '/var/activemq//data/' (pid '27680')

To stop ActiveMQ, you can run the following command.

./bin/activemq stop

Creating Systemd Service

Although you can easily run ActiveMQ using the commands above, it is recommended to use a systemd service for managing ActiveMQ process. Using Systemd service will ensure that ActiveMQ will start automatically at boot time and failures.

Create a systemd service file using your favorite text editor. In this tutorial, we will be using nano editor. If you do not have nano installed, you can run yum -y install nano.

nano /etc/systemd/system/activemq.service

Now populate the file with the following content.

Description=ActiveMQ service

ExecStart=/var/activemq/bin/activemq start
ExecStop=/var/activemq/bin/activemq stop


Now you can start ActiveMQ using:

systemctl start activemq

To configure ActiveMQ to automatically start at boot time, use.

systemctl enable activemq

To check if ActiveMQ service is started correctly, you can run the following command to check the status of the ActiveMQ service.

systemctl status activemq

You should get output similar to shown below.

? activemq.service - ActiveMQ service
   Loaded: loaded (/etc/systemd/system/activemq.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2017-07-15 17:05:24 UTC; 6s ago
  Process: 28815 ExecStart=/var/activemq/bin/activemq start (code=exited, status=0/SUCCESS)
 Main PID: 28867 (java)
   CGroup: /system.slice/activemq.service
           ??28867 /usr/bin/java -Xms64M -Xmx1G

Jul 15 17:05:24 centos systemd[1]: Starting ActiveMQ service...
Jul 15 17:05:24 centos activemq[28815]: INFO: Loading '/var/activemq//bin/env'
Jul 15 17:05:24 centos activemq[28815]: INFO: Using java '/usr/bin/java'
Jul 15 17:05:24 centos activemq[28815]: INFO: Starting - inspect logfiles specified in logging.propertie...tails
Jul 15 17:05:24 centos activemq[28815]: INFO: pidfile created : '/var/activemq//data/' (pid '28867')
Jul 15 17:05:24 centos systemd[1]: Started ActiveMQ service.

Using Admin Web Panel

To access the administrative panel of ActiveMQ, start the ActiveMQ service. Using your favourite web browser, open the following URL.


If you have firewalld installed, you will have to allow port 8161 through the firewall. Run the following command for same.

firewall-cmd --zone=public --permanent --add-port=8161/tcp
firewall-cmd --reload

The initial username and password for Apache ActiveMQ are admin and admin. Once you are logged in, you will see the following interface.

You should change your password as soon as you are logged in.


You can now use Apache ActiveMQ server to manage the communication between multiple clients and servers. You can learn more about Apache ActiveMQ by going to ActiveMQ site.

Share this page:

Suggested articles

5 Comment(s)

Add comment


By: António Trindade

You should not install software in the /var file system. Shouldn't it be /opt or /usr? Why /var?

By: Bernat

You also need to open port 61616 to receive message from outside your server:

firewall-cmd --zone=public --permanent --add-port=61616/tcp


By: sushma

Is it mandatory to have java 8 to intall 5.15.9 or java 7 is sufficient?

By: Alaïa Vee

Followed this guide and had "connection refused" errors trying to access the ActiveMQ console from an outside IP. To resolve the issue I edited the /activemq/conf/jetty.xml, search for webConsolePort, then change the host value from to

    <bean id="jettyPort" class="org.apache.activemq.web.WebConsolePort" init-method="start">

             <!-- the default port number for the web console -->

        <property name="host" value=""/>

        <property name="port" value="8161"/>


By: Jada

The command for installing ActiveMQ didn't work for me... I had to put the url in quotes

# wget "" -O apache-activemq-5.15.8-bin.tar.gz

The site is clever enough to redirect us to the package on the closest mirror, but wget needs double quotes to handle the URL, and we can specify the name of the output file with -O, avoiding an URL as filename.