How to install JBoss AS 7 in RedHat
Wednesday, November 2, 2011 12:58:03 PM
By default, Red Hat 4.1 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.
Installing JBoss AS 7.0.1
Now let's go to install JBoss AS.
Download JBoss AS from JBoss.ORG.
I have choose jboss-as-web-7.0.1.Final (zip format).
Uncompress zip file in /usr/java directory.
[root@neodoo-02 downloads]$ unzip jbossjboss-as-web-7.0.1.Final.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-as-web-7.0.1.Final /opt/java/jboss
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/standalone.sh
By default (due to security reasons) JBoss AS binds only to localhost. If you want to access it via your hostname or IP, then you can edit the JBOSS_HOME/standalone/configuration/standalone.xml to change the "public" and "management" interfaces to point to the hostname of your system:
<interfaces>
<interface name="management">
<inet-address value="your-hostname"/>
</interface>
<interface name="public">
<inet-address value="your-hostname"/>
</interface>
</interfaces>
Once the server is raised, you can access to it in the url http://your_ip_server:8080
Because application server will be run from non-root user for security respects, we may not start it with port 80 and we have to use local port forwarding in order to forward requests from port 80 to port 8080 as follow: You can insert these lines in the /etc/sysconfig/iptables
iptables -F iptables -X iptables -t nat -A OUTPUT -d localhost -p tcp --dport 80 -j REDIRECT --to-ports 8080 iptables -t nat -A OUTPUT -d Your-IP-server -p tcp --dport 80 -j REDIRECT --to-ports 8080 iptables -t nat -A PREROUTING -d Your-IP-server -p tcp --dport 80 -j REDIRECT --to-ports 8080
Then we need to save and restart iptables for applying the changes:
# iptables-save > /etc/sysconfig/iptables # service iptables restart
Please make sure the above changes are saved correctly in /etc/sysconfig/iptables
As we want to Start JBoss on boot we need to create a script to add it a service so it would start at boot up.
we will put it in /etc/init.d/jboss on run level 3 and 5:
-------------------------------------------------------------------------------------------------------
#!/bin/bash
### 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: Start/Stop JBoss AS v7.0.0
### END INIT INFO#
#source some script files in order to set and export environmental variables
#as well as add the appropriate executables to $PATH
[ -r /etc/profile.d/java.sh ] && . /etc/profile.d/java.sh
[ -r /etc/profile.d/jboss.sh ] && . /etc/profile.d/jboss.sh
MYSERVERIP="192.168.42.188"
MYPORT="9999"
case "$1" in
start)
echo "Starting JBoss 1.6.0_20-b02"
su - sokan -c "${JBOSS_HOME}/bin/standalone.sh&" > /dev/null 2>&1
;;
stop)
echo "Stopping JBoss 1.6.0_20-b02"
su - sokan -c "${JBOSS_HOME}/bin/jboss-admin.sh --connect controller=$MYSERVERIP:$MYPORT command=:shutdown" >/dev/null 2>&1
# su - sokan -c "${JBOSS_HOME}/bin/jboss-admin.sh --connect command=:shutdown"
;;
*)
echo "Usage: /etc/init.d/jboss {start|stop}"
exit 1
;;
esac
exit 0
-------------------------------------------------------------------------------------------------------------------------
Then we need to execute following commands:
# chmod 755 /etc/init.d/jboss # cd /etc/rc.d/rc3.d # ln -s ../init.d/jboss S97jboss # cd /etc/rc.d/rc5.d # ln -s ../init.d/jboss S97jboss
Refrence:
How_to_install_JBoss_AS_in_CentOS_/_RedHat_/_Fedora










