rhel6.5安装OpenJDK1.7.0 + JBoss7.1.1 + maven3.0.4
目录
1、安装openJDK1.7.0. 1
1.1、运行安装命令... 1
1.2、确认Java 成功安装... 2
2、安装JBoss7.1.1. 2
2.1、jboss7.1下载... 2
2.2、添加用户... 2
2.3、设置开机启动... 5
2.4、赋予执行权限... 7
2.5、访问... 8
3、安装maven3.0.4. 8
3.1、安装下载apache-maven-3.0.4-bin.tar.gz. 8
3.2、解压到目标目录... 8
3.3、设置环境变量... 8
3.4、测试是否成功... 8
3.5、修改默认的主页... 9
yum install java-1.7.0-openjdk-devel
yum在分析完依赖包之后会要求确认安装,输入y并回车确认安装。
java -version
应该能看到控制台打印java的版本。
http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.tar.gz
tar -zxvf jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.tar.gz
# mv /root/jboss-as-7.1.1.Final /usr/local/jboss
# cd /usr/local/jboss/
# /usr/local/jboss/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): a
Enter the details of the new user to add.
Realm (ManagementRealm) : (回车)
Username : adminjboss
Password : 至少六位密码
Re-enter Password :
About to add user 'adminjboss' for realm 'ManagementRealm'
Is this correct yes/no?yes
Added user 'adminjboss' to file '/usr/local/jboss/standalone/configuration/mgmt-users.properties'
Added user 'adminjboss' to file '/usr/local/jboss/domain/configuration/mgmt-users.properties'
修改 jboss/standalone/configuration/standalone.xml 文件中127.0.0.1 改为 0.0.0.0 可以其他机器访问
启动 配置文件的路径为:
/usr/share/jboss-as-7.1.1.Final/standalone/configuration/standalone.xml
找到interfaces 定义,然后将jboss.bind.address 和 jboss.bind.address.management 两个变量默认值改为 0.0.0.0
<interfaces>
<interface name=”management”>
<inet-address value=”${jboss.bind.address.management:127.0.0.1}”/>
</interface>
<interface name=”public”>
<inet-address value=”${jboss.bind.address:127.0.0.1}”/>
</interface>
<interface name=”unsecure”>
<inet-address value=”${jboss.bind.address.unsecure:127.0.0.1}”/>
</interface>
</interfaces>
修改前
<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>
<interface name=”unsecure”>
<inet-address value=”${jboss.bind.address.unsecure:127.0.0.1}”/>
</interface>
</interfaces>
修改后
如需要修改Jboss HTTP的绑定端口,可以修改行socket-binding。例如将端口改为80:
<socket-binding name=”http” port=”80″/>
注意:绑定端口<1024的话,需要root权限启动Jboss。
[root@mysqlnode2 bin]# /usr/local/jboss/bin/standalone.sh -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0.0.0.0&
# cd /etc/init.d
vi jboss,脚本内容如下:
[java] view plaincopyprint?
#!/bin/sh
#chkconfig: 345 99 10
#description: JBoss auto start-stop script.
# Source function library.
. /etc/rc.d/init.d/functions
# Get config.
. /etc/sysconfig/network
# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0
### CHANGE THE STARTUP PATH TO YOUR START SCRIPT ###
startup='/usr/local/jboss/bin/standalone.sh > /dev/null 2> /dev/null &'
shutdown='killall java'
start(){
echo -n $"Starting JBoss service: "
$startup
RETVAL=$?
echo
}
stop(){
action $"Stopping JBoss service: " $shutdown
RETVAL=$?
echo
}
restart(){
stop
sleep 10
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
#!/bin/sh
#chkconfig: 345 99 10
#description: JBoss auto start-stop script.
# Source function library.
. /etc/rc.d/init.d/functions
# Get config.
. /etc/sysconfig/network
# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0
### CHANGE THE STARTUP PATH TO YOUR START SCRIPT ###
startup='/usr/local/jboss/bin/standalone.sh > /dev/null 2> /dev/null &'
shutdown='killall java'
start(){
echo -n $"Starting JBoss service: "
$startup
RETVAL=$?
echo
}
stop(){
action $"Stopping JBoss service: " $shutdown
RETVAL=$?
echo
}
restart(){
stop
sleep 10
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
#chmod +x jboss
设置memcached随系统启动
# chkconfig --add jboss
# chkconfig jboss on
启动:
service jboss start
停止:
service jboss stop
访问主页
http://193.168.197.242:8080/
访问控制台
http://193.168.197.242:9990/
输入创建的用户名和密码
http://pan.baidu.com/share/link?shareid=2954070206&uk=201385088&fid=741079175
tar -xzvf apache-maven-3.0.4-bin.tar.gz
在/etc/profile文件中加入以下内容(具体路径需要根据安装目录修改,我的安装目录为/usr/local/):
export MAVEN_HOME=/usr/local/apache-maven-3.0.4
PATH=$PATH:$MAVEN_HOME/bin
使用source /etc/profile命令使更改生效。
在命令行输入mvn -v,如果显示包含Apache Maven 3.0.4 的信息,说明安装成功
部署应用测试
[root@mysqlnode2 ~]# unzip jboss-as-quickstarts-7.1.1.CR2-dist.zip
[root@mysqlnode2 ~]# cd jboss-as-quickstarts-7.1.1.CR2
测试helloworld
[root@mysqlnode2 jboss-as-quickstarts-7.1.1.CR2]# cd helloworld
[root@mysqlnode2 helloworld]# /root/apache-maven-3.0.4/bin/mvn package jboss-as:deploy
等待部署完毕后可以在控制台看到已经部署的应用
访问测试
http://192.168.1.109:8080/jboss-as-helloworld/HelloWorld
第一步
[root@mysqlnode2 bin]# vim /root/jboss-as-7.1.1.Final/standalone/configuration/standalone.xml
enable-welcome-root="true" 修改为
enable-welcome-root="false"
第二步
在你要部署的应用程序的WEB-INF文件夹下添加jboss-web.xml文件,里面的内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<context-root>/</context-root>
</jboss-web>
然后重新打包成war包进行部署
这个时间你访问 http://192.168.1.109:8080/ 出现的就是你部署的项目的主页了!