본문 바로가기
IT개발/Server

CentOS 6 jboss7 설치 및 jsp 구동

by dootiger 2020. 8. 16.
반응형

Java-1.7.0_80 (jboss-as-7.1.1_Final 과 호환되려면 java 버전을 6이나 7을 설치해야 함)

/opt/java 폴더에 설치 진행
mkdir /opt/java
cd /opt/java

jdk-7u80 설치
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz"

jre-7u80 설치
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u80-b15/jre-7u80-linux-x64.tar.gz"

jdk, jre 압축 해제
tar xzf jdk-7u80-linux-x64.tar.gz -C /opt/java
tar xzf jre-7u80-linux-x64.tar.gz -C /opt/java

os에 기본적으로 설정되어 있는 명령어를 새로 설치한 프로그램의 경로로 변경
alternatives --install /usr/bin/java java /opt/java/jdk1.7.0_80/bin/java 2
alternatives --config java

javac와 jar의 위치 설정
alternatives --install /usr/bin/jar jar /opt/java/jdk1.7.0_80/bin/jar 2
alternatives --install /usr/bin/javac javac /opt/java/jdk1.7.0_80/bin/javac 2
alternatives --set jar /opt/java/jdk1.7.0_80/bin/jar
alternatives --set javac /opt/java/jdk1.7.0_80/bin/javac

설치 확인
java -version
javac -version

환경변수 설정
ex)vi /etc/profile

내용 삽입
export JAVA_HOME=/opt/java/jdk1.7.0_80
export JRE_HOME=/opt/java/jre1.7.0_80
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

설정 적용
source /etc/profile





jboss-as-7.1.1.Final

/var/tmp 폴더에 jboss-as-7.1.1.Final 설치
wget http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.tar.gz -P /var/tmp

jboss 압축 해제
tar -zxf /var/tmp/jboss-as-7.1.1.Final.tar.gz -C /opt

압축파일 삭제
rm -f /var/tmp/jboss-as-7.1.1.Final.tar.gz

유저 등록 및 권한 설정
useradd -r jboss -d /opt/jboss-as-7.1.1.Final
chown jboss: -R /opt/jboss-as-7.1.1.Final

jboss 인터페이스에 액세스할 수 있도록 설정
vi /opt/jboss-as-7.1.1.Final/standalone/configuration/standalone.xml

내용 삽입
<interface name="management">
    <!-- <inet-address value="${jboss.bind.address.management:127.0.0.1}"/> -->
    <any-ipv4-address/>
</interface>
<interface name="public">
    <!-- <inet-address value="${jboss.bind.address:127.0.0.1}"/> --> <!--주석처리-->
    <any-ipv4-address/>
</interface>

service로 실행 되도록 설정
cp /opt/jboss-as-7.1.1.Final/bin/init.d/jboss-as-standalone.sh /etc/init.d/jboss
chmod +x /etc/init.d/jboss
mkdir /etc/jboss-as

매개변수 삽입
vi /etc/jboss-as/jboss-as.conf

내용 삽입
JBOSS_HOME=/opt/jboss-as-7.1.1.Final
JBOSS_CONSOLE_LOG=/var/log/jboss-console.log
JBOSS_USER=jboss

service로 jboss 실행 및 스타트 업 설정
service jboss start
chkconfig jboss on

새 사용자 계정 생성
cd /opt/jboss-as-7.1.1.Final/bin
./add-user.sh

create management user
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 : //use id
Password :
Re-enter Password :
About to add user 'testuser' for realm 'ManagementRealm'
Is this correct yes/no? y
Added user 'testuser' to file '/opt/jboss-as-7.1.1.Final/standalone/configuration/mgmt-users.properties'
Added user 'testuser' to file '/opt/jboss-as-7.1.1.Final/domain/configuration/mgmt-users.properties'

설치 확인
INDEX 페이지: http://localhost:8080
관리자 페이지: http://localhost:9990
ROOT Directory: welcome-content





JSP 사용 설정

ROOT Directory가 welcome-content일 경우 jsp파일이 compile되지 않음
ROOT Directory를 ROOT.war로 변경해야 jsp파일이 compile 됨 (변경하게 되면 welcome-content에 있는 파일은 'error 404'가 출력됨)

jsp파일 자동 리로드
vi /opt/jboss-as-7.1.1.Final/standalone/configuration/standalone.xml

내용 삽입
<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
<deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" auto-deploy-exploded="true"/>
</subsystem>


ROOT Directory 변경
vi /opt/jboss-as-7.1.1.Final/standalone/configuration/standalone.xml

내용 삽입 및 변경
<subsystem xmlns="urn:jboss:domain:web:1.5" default-virtual-server="default-host" instance-id="${jboss.node.name}" native="false">
<configuration>
<jsp-configuration development="true" check-interval="1" modification-test-interval="1" recompile-on-fail="true" />
</configuration>
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
<connector name="ajp" protocol="AJP/1.3" scheme="http" socket-binding="ajp"/>
<virtual-server name="default-host" enable-welcome-root="false">
<alias name="localhost"/>
<alias name="example.com"/>
</virtual-server>
</subsystem>

ROOT Directory 생성
mkdir /opt/jboss-as-7.1.1.Final/standalone/deployments/ROOT.war

jboss 서비스 재시작
service jboss restart

jsp test
vi /opt/jboss-as-7.1.1.Final/standalone/deployments/ROOT.war/nowTime.jsp

내용 삽입
<%@ page contentType="text/html; charset=UTF-8"%>
<html>
<head><title>HELLO WORLD</title></head>
<body>
현재 시간: <%= new java.util.Date() %>
</body>
</html>

위 과정을 마치면 jsp파일을 사용할 수 있고 welcome-content에 있는 파일은 404에러가 나옴
welcome-content 확인: http://localhost:8080/index.html
ROOT.war 확인: http://localhost:8080/nowTime.jsp

반응형