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-1.4.2.0-40jpp.115.
[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 http://java.sun.com/javase/downloads
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.sh
#
# Java
#
JAVA_HOME=/opt/java/jdk
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=$JAVA_HOME/lib
LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/i386
#JAVA_OPTS="-Djava.awt.headless=true"
export JAVA_HOME PATH CLASSPATH LD_LIBRARY_PATH #JAVA_OPTS
I add execution permissions to the file.
[root@neodoo-02 downloads]$ chmod 755 /etc/profile.d/java.sh
And execute the file for update environment variables.
[root@neodoo-02 downloads]$ . /etc/profile.d/java.sh
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 jboss-5.1.0.GA-jdk6.zip because the sources of the aplication server are compiled with JDK6. Also, you can use jboss-5.1.0.GA.zip which is compiled with JDK5 (forward compatibility).
We uncompress zip file in /usr/java directory.
[root@neodoo-02 downloads]$ unzip jboss-5.1.0.GA-jdk6.zip -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.sh
#
# JBoss AS
#
JBOSS_HOME=/opt/java/jboss
PATH=$PATH:$JBOSS_HOME/bin
export JBOSS_HOME PATH
I add execution permissions to the file.
[root@neodoo-02 downloads]$ chmod 755 /etc/profile.d/jboss.sh
And execute the file for update environment variables.
[root@neodoo-02 downloads]$ . /etc/profile.d/jboss.sh
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/run.sh
By default, this is the same sentence than
[jboss@neodoo-02 bin]$ /opt/java/jboss/bin/run.sh -b 127.0.0.1 -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 0.0.0.0 for any IP address (or -b you_ip_server).
[root@neodoo-02 bin]$ /opt/java/jboss/bin/run.sh -b 0.0.0.0
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]$ ./shutdown.sh -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 jboss_init_redhat.sh /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/jboss.pid
....
JBOSS_HOME=${JBOSS_HOME:-"/opt/java/jboss"}
#define the user under which jboss will run, or use 'RUNASIS' to run as the current user
JBOSS_USER=${JBOSS_USER:-"jboss"}
#make sure java is in your path
JAVAPTH=${JAVAPTH:-"/opt/java/jdk"}
#configuration to use, usually one of 'minimal', 'default', 'all'
JBOSS_CONF=${JBOSS_CONF:-"default"}
#if JBOSS_HOST specified, use -b to bind jboss services to that address
JBOSS_HOST="0.0.0.0"
JBOSS_BIND_ADDR=${JBOSS_HOST:+"-b $JBOSS_HOST"}
...
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
REFERENCES
http://thewiki4opentech.org/index.php/How_to_install_JBoss_AS_in_CentOS_/_RedHat_/_Fedora