Tomcat7 우분투 세팅 과정 정리

입질쾌감 물때표

우분투에서 로컬 세팅 과정

@@ 톰캣 서버를 부팅 대몬 리스트에서 제외한다.

sudo update-rc.d tomcat7 disable default

@@ 적절하게 디렉토리를 세팅해 둔다.

user1@abab-server:~/public_html$ tree
.
├── catalina_base
│   └── conf
│   ├── Catalina
│   │   └── localhost
│   │   ├── docs.xml
│   │   ├── examples.xml
│   │   ├── host-manager.xml
│   │   └── manager.xml
│   ├── catalina.properties
│   ├── context.xml
│   ├── logging.properties
│   ├── policy.d
│   │   ├── 01system.policy
│   │   ├── 02debian.policy
│   │   ├── 03catalina.policy
│   │   ├── 04webapps.policy
│   │   ├── 10examples.policy
│   │   └── 50local.policy
│   ├── server.xml
│   ├── tomcat7
│   │   ├── Catalina
│   │   │   └── localhost
│   │   │   ├── docs.xml
│   │   │   ├── examples.xml
│   │   │   ├── host-manager.xml
│   │   │   └── manager.xml
│   │   ├── catalina.properties
│   │   ├── context.xml
│   │   ├── logging.properties
│   │   ├── policy.d
│   │   │   ├── 01system.policy
│   │   │   ├── 02debian.policy
│   │   │   ├── 03catalina.policy
│   │   │   ├── 04webapps.policy
│   │   │   ├── 10examples.policy
│   │   │   └── 50local.policy
│   │   ├── server.xml
│   │   ├── tomcat-users.xml
│   │   └── web.xml
│   └── web.xml
├── abab_for_business
└── abab_for_telehouse

 

@@ 디렉토리 복사

user1@abab-server:~/public_html/catalina_base$ sudo cp -r /etc/tomcat7 conf

 

@@ ROOT.xml 설정

user1@abab-server:~/public_html/abab_for_business$ vi ~/public_html/catalina_base/conf/Catalina/localhost/ROOT.xml

 

@@ 만일 vi ~/public_html/catalina_base/conf/Catalina/localhost/abab_for_business.xml 라고 작성되면 서브 어플리케이션이 된다.

<Context path="/abab_for_business" docBase="/home/user1/public_html/abab_for_business/WebContent" reloadable="true" privileged="true" antiResourceLocking="false" antiJARLocking="false">

<!--<Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true" />-->

</Context>

 

URL은 다음과 같이 된다.
http://192.168.0.104:8080/abab_for_business/default.jsp 이 URL은 ~/public_html/abab_for_business/WebContent로 연결된다.

<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--

Context configuration file for the Tomcat Manager Web App

$Id: manager.xml 562814 2007-08-05 03:52:04Z markt $

-->

<Context path="/" docBase="/home/user1/public_html/abab_for_business/"
reloadable="true" privileged="true" antiResourceLocking="false" antiJARLocking="false">

<!--<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true" />-->

</Context>

 

@@ 실행

/usr/lib/jvm/java-7-openjdk-amd64/bin/java \
-agentlib:jdwp=transport=dt_socket,server=y,address=localhost:35001,suspend=n \
-Djava.util.logging.config.file=/home/user1/public_html/catalina_base/conf/logging.properties \
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \
-Djava.endorsed.dirs=/usr/share/tomcat7/endorsed \
-classpath /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar \
-Dcatalina.base=/home/user1/public_html/catalina_base \
-Dcatalina.home=/usr/share/tomcat7 \
-Djava.io.tmpdir=/home/user1/public_html/catalina_base/tmp/ \
org.apache.catalina.startup.Bootstrap \
start

 

@@ eclipse에서 생성한 build 컴파일 자파클래스 CLASSPATH 추가시 실행 && tomcat library 추가 설정 && WEB-INF/lib 라이브러리 추가 등록

/usr/lib/jvm/java-7-openjdk-amd64/bin/java \
-agentlib:jdwp=transport=dt_socket,server=y,address=localhost:35001,suspend=n \
-Djava.util.logging.config.file=/home/user1/public_html/catalina_base/conf/logging.properties \
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \
-Djava.endorsed.dirs=/usr/share/tomcat7/endorsed \
-classpath /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar:/home/user1/public_html/abab_for_business/WebContent/build/classes:/usr/share/tomcat7/lib/*:/home/user1/public_html/dacom_for_business/WebContent/WEB-INF/lib/* \
-Dcatalina.base=/home/user1/public_html/catalina_base \
-Dcatalina.home=/usr/share/tomcat7 \
-Djava.io.tmpdir=/home/user1/public_html/catalina_base/tmp/ \
org.apache.catalina.startup.Bootstrap \
start

 

@@ index.html 파일 생성 테스트

@ 톰캣 Stop 스크립트

ps aux | grep abab_for_business | awk '{print $2}' | xargs -I number kill -9 number

 

@@ 톰캣 서버를 ROOT로 붙이려면 ROOT.xml이 있어야 한다.

user1@abab-server:~/public_html/abab_for_business/catalina_base/conf/Catalina/localhost$ ls -ail
total 28
52166672 drwxrwxr-x 2 user1 user1 4096 Oct 21 11:20 .
52166671 drwxrwxr-x 3 user1 user1 4096 Sep 18 14:53 ..
52166675 -rw-r--r-- 1 user1 user1 922 Sep 18 14:53 docs.xml
52166674 -rw-r--r-- 1 user1 user1 97 Sep 18 14:53 examples.xml
52166673 -rw-r--r-- 1 user1 user1 958 Sep 18 14:53 host-manager.xml
52166676 -rw-r--r-- 1 user1 user1 948 Sep 18 14:53 manager.xml
52168220 -rw-rw-r-- 1 user1 user1 1620 Oct 21 11:08 ROOT.xml

 

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다