在CentOS 6上安装JBoss 7.1
Install JBoss 7.1 on CentOS 6
This post will cover installing JBoss 7.1.1 on CentOS 6.x.
We’ll also set up JBoss to run as a service, as well as set up access to the management console
Finally, we will look at how run JBoss on port 80 or, alternatively, placing JBoss behind Apache.
In this post, we will set up the JBoss 7.1.1 in Standalone mode. In a subsequent post we will look at setting up JBoss 7.1.1 in Domain mode.
Step 1: Install the Java 6 or 7
Firstly, we will need to install Java.
JBoss 7.1.1 will work with JDK 6 or JDK 7.
I’m using JDK 7, update 5.
You can download the JDK here: http://www.oracle.com/technetwork/java/javase/downloads/index.html
The instructions below will also work with JDK 6, you just need to change the file names accordingly.
Start by creating a directory /usr/java.
|
|
[root@dev2 java]# ls
jdk-7u5-linux-x64.tar.gz
|
|
[root@dev2 java]# tar -zxf jdk-7u5-linux-x64.tar.gz
|
|
[root@dev2 java]# ls
jdk1.7.0_05 jdk-7u5-linux-x64.tar.gz
[root@dev2 java]# cd jdk1.7.0_05
[root@dev2 jdk1.7.0_05]# pwd
/usr/java/jdk1.7.0_05
|
|
[root@dev2 ~]#cd /usr/java
[root@dev2 java]# sh /opt/jdk-6u33-linux-x64.bin
|
|
[root@dev2 jdk1.7.0_05]# cd /usr/share
|
|
[root@dev2 share]# wget http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip
|
|
[root@dev2 share]# unzip -q jboss-as-7.1.1.Final.zip
|
|
[root@dev2 share]# mv jboss-as-7.1.1.Final jboss-as
|
|
[root@dev2 share]# cd jboss-as
[root@dev2 jboss-as]# pwd
/usr/share/jboss-as
|
|
[root@dev2 share]# groupadd jboss
[root@dev2 share]# useradd -s /bin/bash -g jboss jboss
|
|
[root@dev2 share]# chown -Rf jboss.jboss /usr/share/jboss-as/
|
|
JAVA_HOME=/usr/java/jdk1.7.0_05
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
|
|
[root@dev2 ~]# . ~/.bash_profile
|
|
[root@dev2 ~]# java -version
java version “1.7.0_05”
Java(TM) SE Runtime Environment (build 1.7.0_05-b06)
Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)
[root@dev2 ~]#
|
|
[root@dev2 ~]# su - jboss
[jboss@dev2 ~]$ java -version
java version “1.7.0_05”
Java(TM) SE Runtime Environment (build 1.7.0_05-b06)
Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)
[jboss@dev2 ~]$
|
|
[root@dev2 ~]# cd /usr/share/jboss-as/bin/init.d
[root@dev2 bin]# cp jboss-as-standalone.sh /etc/init.d/jboss
|
|
JBOSS_USER=jboss
export JBOSS_USER
|
|
#!/bin/sh
JBoss standalone control script
chkconfig: 234 80 20
description: JBoss AS Standalone
processname: standalone
pidfile: /var/run/jboss-as/jboss-as-standalone.pid
config: /etc/jboss-as/jboss-as.conf
Source function library.
. /etc/init.d/functions
Load Java configuration.
[ -r /etc/java/java.conf ] && . /etc/java/java.conf
export JAVA_HOME
JBOSS_USER=jboss
export JBOSS_USER
Load JBoss AS init.d configuration.
if [ -z “$JBOSS_CONF” ]; then
JBOSS_CONF="/etc/jboss-as/jboss-as.conf"
fi
[ -r “$JBOSS_CONF” ] && . “${JBOSS_CONF}”
Set defaults.
if [ -z “$JBOSS_HOME” ]; then
JBOSS_HOME=/usr/share/jboss-as
fi
export JBOSS_HOME
|
|
[root@dev2 init.d]# chmod 755 jboss
[root@dev2 init.d]# chkconfig –add jboss
[root@dev2 init.d]# chkconfig –level 234 jboss on
|
|
[root@dev2 init.d]# service jboss start
Starting jboss-as: [ OK ]
[root@dev2 init.d]#
|
|
[root@dev2 init.d]# service jboss stop
Stopping jboss-as: *** JBossAS process (25794) received TERM signal ***
[ OK ]
|
|
|
|
|
|
[root@dev2 init.d]# service jboss start
Starting jboss-as: [ OK ]
|
|
[root@dev2 etc]# cd /usr/share/jboss-as/bin
|
|
[root@dev2 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):
Enter the details of the new user to add.
Realm (ManagementRealm) :
Username : david
Password :
Re-enter Password :
About to add user ‘david’ for realm ‘ManagementRealm’
Is this correct yes/no? yes
Added user ‘david’ to file ‘/usr/share/jboss-as/standalone/configuration/mgmt-users.properties’
Added user ‘david’ to file ‘/usr/share/jboss-as/domain/configuration/mgmt-users.properties’
[root@dev2 bin]#
|
|
|
|
|
|
[root@sv2 ~]# iptables -t nat -A PREROUTING -p tcp -m tcp –dport 80 -j REDIRECT –to-ports 8080
[root@sv2 ~]# iptables -t nat -A PREROUTING -p udp -m udp –dport 80 -j REDIRECT –to-ports 8080
|
|
ServerAdmin [email protected]
ServerName domain.com
ServerAlias www.domain.com
ProxyRequests Off
ProxyPreserveHost On
Order allow,deny
Allow from all
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
ErrorLog logs/domain.com-error_log
CustomLog logs/domain.com-access_log common
|
|
ServerAdmin [email protected]
ServerName domain.com
ServerAlias www.domain.com
ProxyRequests Off
ProxyPreserveHost On
Order allow,deny
Allow from all
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/
ErrorLog logs/domain.com-error_log
CustomLog logs/domain.com-access_log common
|
|
ServerAdmin [email protected]
ServerName domain.com
ServerAlias www.domain.com
RewriteEngine On
RewriteRule ^/$ myapp/ [R=301]
ProxyRequests Off
ProxyPreserveHost On
Order allow,deny
Allow from all
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/
ErrorLog logs/domain.com-error_log
CustomLog logs/domain.com-access_log common
|
|