Monday, April 26, 2010

How to install JBoss AS in CentOS / RedHat / Fedora

SkyHi @ Monday, April 26, 2010

In this HOWTO, we are using CentOS 5.0, JDK6 and JBoss 5.1.x.

[edit] Installing Java SE 6

Let's go !

By default, CentOS 5.0 contains the package java-1.4.2-gcj-compat-

   [neodoo@neodoo-02 downloads]$ java --version
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2-44)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PART ...

First, you have to install the latest Java SE Development Kit (JDK) that you can download from

In this article, I have download Java SE Development Kit 6u16 for Platform Linux x64 (jdk-6u16-linux-x64-rpm.bin).

For install JDK, you have to put execution permissions to the file.

   [root@neodoo-02 downloads]$ chmod 755 jdk-6u16-linux-x64-rpm.bin
   [root@neodoo-02 downloads]$ ./jdk-6u16-linux-x64-rpm.bin

You can verify that Java SE is installed in /usr/java/

I verify the Java version of the operating system.

   [root@neodoo-00 downloads]# java -version
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode)

I create dynamic links that let us not to modify scripts if I change Java versions.

   [root@neodoo-00 downloads]# mkdir /opt/java
   [root@neodoo-02 downloads]$ ln -s /usr/java/jdk1.6.0_16 /opt/java/jdk

Next, I create the environment variables for Java

   [root@neodoo-02 downloads]$ sudo vi /etc/profile.d/

# Java



I add execution permissions to the file.

   [root@neodoo-02 downloads]$ chmod 755 /etc/profile.d/

And execute the file for update environment variables.

   [root@neodoo-02 downloads]$ . /etc/profile.d/

This operation let us to maintain scripts intact and upgrade versions only changing dynamic links.

[edit] Installing JBoss AS 5.1.x

Now let's go to install JBoss AS.

Download JBoss AS from JBoss.ORG.

I have choose JBoss AS 5.1.0.GA (zip format).

Because I have installed JDK6, I have downloaded because the sources of the aplication server are compiled with JDK6. Also, you can use which is compiled with JDK5 (forward compatibility).

We uncompress zip file in /usr/java directory.

  [root@neodoo-02 downloads]$ unzip -d /usr/java/

I create dynamic links that let us not to modify scripts if I change JBoss AS versions.

   [root@neodoo-00 downloads]# ln -s /usr/java/jboss-5.1.0.GA /opt/java/jboss

We create environment variables for JBoss

   [root@neodoo-02 ~]# vi /etc/profile.d/
# JBoss AS



I add execution permissions to the file.

   [root@neodoo-02 downloads]$ chmod 755 /etc/profile.d/

And execute the file for update environment variables.

   [root@neodoo-02 downloads]$ . /etc/profile.d/

I create a new user called jboss and assign this user to jboss directory. Don't start JBoss AS with root user !

   [root@neodoo-02 ~]# adduser jboss
   [root@neodoo-02 bin]$ chown -Rf jboss.jboss /opt/java/jboss/

You can start JBoss AS manually.

   [root@neodoo-00 bin]# su jboss
   [jboss@neodoo-02 bin]$ /opt/java/jboss/bin/

By default, this is the same sentence than

   [jboss@neodoo-02 bin]$ /opt/java/jboss/bin/ -b -c default

With this sentence, you will only access to JBoss AS from localhost.

If you want to access from a remote IP, put -b for any IP address (or -b you_ip_server).

   [root@neodoo-02 bin]$ /opt/java/jboss/bin/ -b

By default, we use default profile which it corresponds to the directory $JBOSS_HOME/server/default that JBoss AS uses.

You will see a log detail from JBoss AS in the console and if JBoss AS starts OK, you will see something like this:

   15:53:50,035 INFO  [ServerImpl] JBoss (Microcontainer) [5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221634)] Started in 1m:15s:485ms

Once the server is raised, you can access to it in the url http://your_ip_server:8080


You can stop JBoss AS with CTRC-L o using this sentence in another console

  [jboss@neodoo-00 bin]$ ./ -S

Now, we are going to create JBoss service. Remember to return to root user (exit).

   [root@neodoo-02 bin]$ cd /opt/java/jboss/bin
   [root@neodoo-02 bin]$ cp /etc/init.d/jboss
   [root@neodoo-02 bin]$ chmod +x /etc/init.d/jboss

I modify this file:

   [root@neodoo-02 bin]$ vi /etc/init.d/jboss
   # chkconfig: - 64 36
# description: Jboss Start|Restart|Stop Application Server
# pidfile: /var/run/



#define the user under which jboss will run, or use 'RUNASIS' to run as the current user

#make sure java is in your path

#configuration to use, usually one of 'minimal', 'default', 'all'

#if JBOSS_HOST specified, use -b to bind jboss services to that address


Look that JBOSS_HOST corresponds to -c ip_server, JBOSS_CONF to -b profile and JBOSS_USER to user that starts JBoss AS like a service.

We are going to add JBoss like a service.

   [root@neodoo-02 init.d]# chkconfig --add jboss
   [root@neodoo-02 init.d]# chkconfig --list
   [root@neodoo-02 init.d]# chkconfig jboss --level 3 on

You can start JBoss AS

   [root@neodoo-02 bin]$ service jboss start

If you can't access, verify you don't have any mistake or you have iptables on blocking port 8080.

   [root@neodoo-02 bin]$ sudo /etc/init.d/iptables stop

or check that your security allow tcp connection to port 8080

   [root@neodoo-02 bin]$ system-config-securitylevel

choose Customized from Graphical menu and insert 8080:tcp into Other ports

You can stop JBoss AS

   [root@neodoo-02 bin]$ service jboss stop