How to install JBoss AS on Ubuntu

Today I installed JBoss AS 7.1 on our Ubuntu 13.04 stend. I'm sure it is not the last time when I prepare JBoss application server, so I decided to memorize my steps in this post.

The installation procedure is:

Install JDK 7

Install JDK from repository (oracle-java7-installer from this ppa is JDK)
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

Set this version to be used by default
sudo update-java-alternatives -s java-7-oracle
Set up environment variables
sudo apt-get install oracle-java7-set-default

Install JBoss AS 7.1.1

Download and unpack JBoss AS 7.1.1. For manually installed software I use old-fashioned /opt folder.
wget http://download.jboss.org/jbossas/7.1/jbos-as-7.1.1.Final/jboss-as-7.1.1.Final.tar.gz
tar xfvz jboss-as-7.1.1.Final.tar.gz
sudo mv jboss-as-7.1.1.Final /opt/jbossas7

Create jboss service user, give permissions, enter as jboss
adduser jboss
chown -R jboss:jboss /opt/jbossas7
su jboss

Add new management user, when adding, press "a" to select management user, leave ManagementRealm and enter admin username and password:
adduser
 

Test run JBoss AS 

Change user to jboss
su jboss
Run with remote access management allowed
/opt/jbossas7/bin/standalone.sh -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0.0.0.0
Open a management console in browser http://localhost:9990
Open default web http://localhost:8080
Just press Ctrl-C in terminal to stop the server

Configure to run as a daemon

Create script
 /etc/init.d/jbossas7
with the following content:

#!/bin/sh
 
### BEGIN INIT INFO
# Provides: jboss
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Management of JBoss AS v7.x
### END INIT INFO
 
#Defining JBOSS_HOME
JBOSS_HOME=/opt/jbossas7/
 
case "$1" in
start)
echo "Starting JBoss AS7…"
sudo -u jboss sh ${JBOSS_HOME}/bin/standalone.sh &
;;
stop)
echo "Stopping JBoss AS7…"
sudo sh ${JBOSS_HOME}/bin/jboss-cli.sh –connect command=:shutdown
;;
log)
echo "Showing server.log…"
tail -1000f ${JBOSS_HOME}/standalone/log/server.log
;;
*)
echo "Usage: /etc/init.d/jboss {start|stop|log}"
exit 1
;; esac
exit 0

Set the script as executable
chmod +x /etc/rc.d/init.d/jbossas7 

Test it
sudo service jbossas7 start
sudo service jbossas7 stop

 

And finally make it auto run when system starts
update-rc.d jbossas7 defaults

Allow remote access

JBoss restricts remote access by default. To be able to open JBoss console and apps in browser from any remote machine, do the following steps.

Open config file /opt/jbossas7/standalone/configuration/standalone.xml, change addresses from 127.0.0.1 to 0.0.0.0 in interfaces section:

<interfaces>
    <interface name="management">
        <inet-address value="${jboss.bind.address.management:0.0.0.0}" />
    </interface>
    <interface name="public">
        <inet-address value="${jboss.bind.address:0.0.0.0}" />
    </interface>
    <interface name="unsecure">
        <inet-address value="${jboss.bind.address.unsecure:0.0.0.0}" />
    </interface>
</interfaces>
 
Now we can open  http://my-jboss-server-name:8080 and http://my-jboss-server-name:9990 from another machine

Leave a Reply

Your email address will not be published.