Linux环境下JDK,JBOSS以及MySQL的安装配置(3)

三、JBOSS的安装配置

jboss版本选用jboss4.0.3,下载地址:,不过本人使用的是一个已经解压缩好的文件夹

用root登录系统开始安装

1,假设jboss4.0.3文件夹位于/usr/local/suncer/server目录下运行命令

#将jboss_init_RedHat.sh复制到启动目录下并重命名为jboss

cp /usr/local/suncer/server/jboss4.0.3/bin/jboss_init_redhat.sh /etc/rc.d/init.d/jboss

2,打开/etc/rc.d/init.d/jboss文件,修改其中的配置:

JBOSS_HOME=${JBOSS_HOME:-"/usr/local/suncer/server/jboss4.0.3"}
JavaPTH=${JAVAPTH:-"/usr/java/jdk1.5.0_16/bin"}
JBOSSCP=${JBOSSCP:-"$JBOSS_HOME/bin/shutdown.sh -S"}
JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh"}
JBOSSUS=${JBOSSUS:-"root"}
CMD_START="$JBOSSSH"
CMD_STOP="cd $JBOSS_HOME/bin; $JBOSSCP"

修改完毕正确的文件内容如下:

#!/bin/sh
#
# JBoss Control Script
#
# chkconfig: 3 80 20
# description: JBoss EJB Container
#
# To use this script
# run it as root - it will switch to the specified user
# It loses all console output - use the log.
#
# Here is a little (and extremely primitive)
# startup/shutdown script for RedHat systems. It assumes
# that JBoss lives in /usr/local/jboss, it's run by user
# 'jboss' and JDK binaries are in /usr/local/jdk/bin. All
# this can be changed in the script itself.
# Bojan
#
# Either amend this script for your requirements
# or just ensure that the following variables are set correctly
# before calling the script
# [ #420297 ] JBoss startup/shutdown for RedHat
#define where jboss is - this is the directory containing directories log, bin, conf etc
JBOSS_HOME=${JBOSS_HOME:-"/usr/local/suncer/server/jboss4.0.3"}
#make java is on your path
JAVAPTH=${JAVAPTH:-"/usr/local/suncer/server/jdk1.5.0/bin"}
#define the classpath for the shutdown class
JBOSSCP=${JBOSSCP:-"$JBOSS_HOME/bin/shutdown.sh -S"}
#define the script to use to start jboss
JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh"}
if [ -n "$JBOSS_CONSOLE" -a ! -d "$JBOSS_CONSOLE" ]; then
# ensure the file exists
touch $JBOSS_CONSOLE
fi
if [ -n "$JBOSS_CONSOLE" -a ! -f "$JBOSS_CONSOLE" ]; then
echo "WARNING: location for saving console log invalid: $JBOSS_CONSOLE"
echo "WARNING: ignoring it and using /dev/null"
JBOSS_CONSOLE="/dev/null"
fi
#define what will be done with the console log
JBOSS_CONSOLE=${JBOSS_CONSOLE:-"/dev/null"}
#define the user under which jboss will run, or use RUNASIS to run as the current user
JBOSSUS=${JBOSSUS:-"root"}
CMD_START="$JBOSSSH"
CMD_STOP="cd $JBOSS_HOME/bin; $JBOSSCP"
if [ "$JBOSSUS" = "RUNASIS" ]; then
SUBIT=""
else
SUBIT="su - $JBOSSUS -c "
fi
if [ -z "`echo $PATH | grep $JAVAPTH`" ]; then
export PATH=$PATH:$JAVAPTH
fi
if [ ! -d "$JBOSS_HOME" ]; then
echo JBOSS_HOME does not exist as a valid directory : $JBOSS_HOME
exit 1
fi
echo CMD_START = $CMD_START
case "$1" in
start)
cd $JBOSS_HOME/bin
if [ -z "$SUBIT" ]; then
eval $CMD_START >${JBOSS_CONSOLE} 2>&1 &
else
$SUBIT "$CMD_START >${JBOSS_CONSOLE} 2>&1 &"
fi
;;
stop)
if [ -z "$SUBIT" ]; then
$CMD_STOP
else
$SUBIT "$CMD_STOP"
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "usage: $0 (start|stop|restart|help)"
esac
—……………………

3,配置环境变量,与JDK环境变量配置方法相同,打开/etc/profile文件,在JDK环境变量处添加如下字串:

JBOSS_HOME=/usr/local/suncer/server/jboss4.0.3

修改PATH,PATH=$PATH:$JAVA_HOME/bin:$JBOSS_HOME/bin

在export后面加上 JBOSS_HOME

4,使jboss自动启动:

打开/etc/rc.d/rc.local文件,在文件后面添加如下字串,

/etc/rc.d/init.d/jboss start

5,对/etc/rc.d/init.d/jboss、/usr/local/suncer/server/jboss4.0.3/bin/run.sh以及shutdown.sh执行如下命令:

chmod +x filepath/filename使这些文件可以被执行。

6,重启服务器

JBOSS配置完毕

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyxjxp.html