Install jboss 7.1.1 with jdk 7 on CentOS RHEL Fedora Debian Ubuntu

Overview

JavaBeans Open Source Software Application Server (JBoss AS, or simply JBoss) is an application server that implements the Java Platform, Enterprise Edition (Java EE).
JBoss is written in Java and as such is cross-platform: usable on any operating system that supports Java.
JBoss was developed by JBoss, now a division of Red Hat. Licensed under the terms of the GNU Lesser General Public License, JBoss is free and open source software. Source wikipedia.org

Install jboss 7.1.1 with jdk 7 on CentOS RHEL Fedora Debian Ubuntu

JBoss require JDK to be installed on your machine, so lets install it first.


# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2F
www.oracle.com%2F" "http://download.oracle.com/otn-pub/java/jdk/7u25-b15/jdk-7u25-linux-x64.tar.gz"
# tar zxvf jdk-7u25-linux-x64.tar.gz
# mkdir /usr/java
# mv jdk1.7.0_25/ /usr/java/

On CentOS, RHEL. Fedora


# alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_25/jre/bin/java 2000

On Debian, Ubuntu


# update-alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_25/jre/bin/java 2000

Verify java version


# java -version

java version “1.7.0_25″
Java(TM) SE Runtime Environment (build 1.7.0_25-b20)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)

If you see some other version then use alternatives --config or update-alternatives --config to select the correct version.

On CentOS, RHEL, Fedora

# alternatives --config java

There are 3 programs which provide 'java'.

Selection Command
-----------------------------------------------
* 1 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
2 /usr/java/latest/jre/bin/java
+ 3 /usr/java/jdk1.7.0_25/jre/bin/java

Enter to keep the current selection[+], or type selection number: 3

As you can see that I also have openjdk 1.6 installed and active(java with [+] is currently in use). Selecting the 3rd option will make the latest 1.7 active, you can run java -version to verify it.

On Debian, Ubuntu

# update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/java/jdk1.7.0_25/jre/bin/java 2000 auto mode
1 /usr/java/jdk1.7.0_25/jre/bin/java 2000 manual mode
2 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode

Press enter to keep the current choice[*], or type selection number:

Download the latest version of JBoss AS


# cd /tmp
# wget http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip

Untar it and move it to a destination of choice, I will use /usr/share


# tar zxvf jboss-as-7.1.1.Final.tar.gz
# mv jboss-as-7.1.1.Final /usr/share/jboss-as

Add a new user and group for jboss, if you are brave enough to run jboss as root skip this step.


# groupadd jboss-as
# useradd -s /bin/bash -g jboss-as -d /usr/share/jboss-as jboss-as

Change permissions.


# chown -Rf jboss-as.jboss-as /usr/share/jboss-as/

Move the startup script provided with the package and the configuration file to respective directories.


# mkdir /etc/jboss-as
# cd /usr/share/jboss-as/bin/init.d
# cp jboss-as.conf /etc/jboss-as/
# cp jboss-as-standalone.sh /etc/init.d/jboss-as

Open the configuration file in an editor of choice


# vi /etc/jboss-as/jboss-as.conf

Uncomment JBOSS_USER and JBOSS_CONSOLE_LOG


JBOSS_USER=jboss-as
JBOSS_CONSOLE_LOG=/var/log/jboss-as/console.log

On Debian and Ubuntu, you need to perfom this additional step. Open the init script in an editor of choice


# vi /etc/init.d/jboss-as

Edit line 1 and change it to


#!/usr/bin/env bash

Also replace line 12 with the following


. /lib/lsb/init-functions

Lastly comment out line 111 and 138


#success

Install chkconfig if as its not installed by default on Ubuntu, Debian

On Debian, Ubuntu


# apt-get install chkconfig

Start jboss server and add it to chkconfig so it automatically starts on server reboots.


# chmod 755 /etc/init.d/jboss-as
# chkconfig --add jboss-as
# chkconfig --level 234 jboss-as on
# /etc/init.d/jboss-as start

Run netstat to confirm jboss starts listening on 8080, by default the server listens on the loopback address, to change this behavior edit standalone.xml file.

# netstat -tunlp | grep 8080
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 55856/java

Open the standalone.xml file in an editor of choice


# vi /usr/share/jboss-as/standalone/configuration/standalone.xml

Change jboss bind address for management and public interfaces to ip address it should listen on. I changed it to 0.0.0.0 so that it listens on every available interface.


<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>
<!-- TODO - only show this if the jacorb subsystem is added -->
<interface name="unsecure">
<!--
~ Used for IIOP sockets in the standard configuration.
~ To secure JacORB you need to setup SSL
-->
<inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/>
</interface>
</interfaces>

At this point if you try access Jboss Management Interface at http://ipaddress-or-domainname:9990, you will be greeted with the following error.

jboss02 300x176 Install jboss 7.1.1 with jdk 7 on CentOS RHEL Fedora Debian Ubuntu

Add a new user


# cd /usr/share/jboss-as/bin/
# ./add-user.sh

What type of user do you wish to add?
a) Management User (mgmt-users.properties)
b) Application User (application-users.properties)
(a):

Enter the details of the new user to add.
Realm (ManagementRealm) :
Username : ryan
Password :
Re-enter Password :
About to add user ‘ryan’ for realm ‘ManagementRealm’
Is this correct yes/no? yes
Added user ‘ryan’ to file ‘/usr/share/jboss-as/standalone/configuration/mgmt-users.properties’
Added user ‘ryan’ to file ‘/usr/share/jboss-as/domain/configuration/mgmt-users.properties’

jboss03 300x187 Install jboss 7.1.1 with jdk 7 on CentOS RHEL Fedora Debian Ubuntu

jboss04 300x187 Install jboss 7.1.1 with jdk 7 on CentOS RHEL Fedora Debian Ubuntu

By default Jboss will listen on port 8080, however you can use ip tables to route traffic from port 8080 to port 80


# iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
# iptables -t nat -A PREROUTING -p udp -m udp --dport 80 -j REDIRECT --to-ports 8080
# service iptables save
# service iptables restart

Or run apache in front of JBoss

On CentOS, RHEL

Install apache


# yum install httpd

Open the apache configuration file and add a virtual host.


# vi /etc/httpd/conf/httpd.conf

Append the following code to it.


<VirtualHost *:80>
ServerAdmin admin@linuxdrops.com
ServerName linuxdrops.com

ProxyRequests Off

<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/

ErrorLog logs/jboss-apache-error_log
CustomLog logs/jboss-apache-access_log common
</VirtualHost>

On Debian, Ubuntu

Install apache


# apt-get install apache2

Enable proxy modules


# a2enmod proxy
# a2enmod proxy_http

Open the default site config file in an editor


# vi /etc/apache2/sites-enabled/000-default

Add the ProxyPass and ProxyPassReverse to it.


<VirtualHost *:80>
ServerAdmin webmaster@localhost
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
<!--more configuration goes here>
</VirtualHost>

jboss01 300x176 Install jboss 7.1.1 with jdk 7 on CentOS RHEL Fedora Debian Ubuntu