프로그램

[was][tomcat] 톰캣 Document Root 설정 방법

지승준 2014. 6. 26. 18:13

server.xml에 보면 <Host> 태그의 appBase 속성이 있고, <Host> 태그 내에 

<Context> 태그 속성에 docBase 가 있다. 

이 둘 태그를 사용한 server.xml 에서 웹 어플리케이션의 Document Root를 설정하는 방법에 대해서 알아보자


1. 톰켓의 기본 Document Root

2. <Context> 태그의 사용

3. 원하는 디렉토리를 Document Root로 사용


문서에 대하여


1. 톰켓의 기본 Document Root

톰캣의 기본 Document Root는 webapps/ROOT 이다.

server.xml의 <Host> 태그는 아래와 같이 설정되어 있고, <Context> 태그가 생략되어 있다.

1
2
3
4
5
 <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
 ..
 </Host>      
cs

appBase는 $CATALINA_HOME 디렉토리 밑 상대경로를 기본 인자로 받는다.

<Context> 태그가 생략되어 있으면 기본적인 루트는 ROOT 디렉토리 밑이 된다.



2. <Context> 태그의 사용

<Context> 태그를 사용해 appBase 하위 디렉토리를 Document Root로 지정 할 수 있다.

webapps/web 을 Document Root 로 지정한 예제

1
2
3
4
5
6
 <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
    <Context path="" docBase="web" reloadable="true"/>
..
 </Host>
cs


3. 원하는 디렉토리를 Document Root로 사용

위의 appBase를 절대 경로로 지정하고 docBase를 현재 디렉토리로 설정하면 된다.

1
2
3
4
5
6
 <Host name="localhost"  appBase="/home/user/oramaster/public_html"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
    <Context path="" docBase="." reloadable="true"/>
..
 </Host>
cs

위의 appBase를 기본값으로 나두고 docBase를 절대경로로 지정하여도 된다.

1
2
3
4
5
6
<Host name="localhost"  appBase="webapps" 
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
    <Context path="" docBase="/home/user/oramaster/public_html" reloadable="true"/>
..
 </Host>
cs

<Context> 를 사용하지 않으면 ROOT를 자동으로 Document Root로 사용 한 다는 것을 기억하자.