2009/07/09 Apache Tomcat 6.0 - Virtual Hosting and Tomcat

[출처] http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html


Apache Tomcat 6.0

Virtual Hosting and Tomcat

Assumptions

For the sake of this how-to, assume you have a development host with two host names, ren and stimpy. Let's also assume one instance of Tomcat running, so $CATALINA_HOME refers to wherever it's installed, perhaps /usr/local/tomcat.

Also, this how-to uses Unix-style path separators and commands; if you're on Windows modify accordingly.

server.xml

At the simplest, edit the Engine portion of your server.xml file to look like this:

<Engine name="Catalina" defaultHost="ren">
    <Host name="ren"    appBase="renapps"/>
    <Host name="stimpy" appBase="stimpyapps"/>
</Engine>
    

Note that the directory structures under the appBase for each host should not overlap each other.

Consult the configuration documentation for other attributes of the Engine and Host elements.

Webapps Directory

Create directories for each of the virtual hosts:

mkdir $CATALINA_HOME/renapps
mkdir $CATALINA_HOME/stimpyapps
    
Configuring Your Contexts
General

Contexts are normally located underneath the appBase directory. For example, to deploy the foobar context as a war file in the ren host, use $CATALINA_HOME/renapps/foobar.war. Note that the default or ROOT context for ren would be deployed as $CATALINA_HOME/renapps/ROOT.war (WAR) or $CATALINA_HOME/renapps/ROOR (directory).

NOTE: The docBase for a context should never be the same as the appBase for a host.

context.xml - approach #1

Within your Context, create a META-INF directory and then place your Context definition in it in a file named context.xml. i.e. $CATALINA_HOME/renapps/ROOT/META-INF/context.xml This makes deployment easier, particularly if you're distributing a WAR file.

context.xml - approach #2

Create a structure under $CATALINA_HOME/conf/Catalina corresponding to your virtual hosts, e.g.:

mkdir $CATALINA_HOME/conf/Catalina/ren
mkdir $CATALINA_HOME/conf/Catalina/stimpy
      

Note that the ending directory name "Catalina" represents the name attribute of the Engine element as shown above.

Now, for your default webapps, add:

$CATALINA_HOME/conf/Catalina/ren/ROOT.xml
$CATALINA_HOME/conf/Catalina/stimpy/ROOT.xml
      

If you want to use the Tomcat manager webapp for each host, you'll also need to add it here:

cd $CATALINA_HOME/conf/Catalina
cp localhost/manager.xml ren/
cp localhost/manager.xml stimpy/
      
Further Information

Consult the configuration documentation for other attributes of the Context element.

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기

2009/07/09 10:53 Trackback 0 Comment 0
Trackback Address : http://marine.pe.kr/trackback/1505
[로그인][오픈아이디란?]
id    pw    homepage    secret
  • Marine™태터툴즈로 갈아타면서 데이터를 이관하...
  • 음...머좀 볼려고했는데 글씨가 하나도 안보...
  • 구리구리좋은글 잘 봤습니다. 퍼갈께요~.
  • anas볼띠...변태였구나 (_ _);;
  • anas이 노래는 저도 아무때나 흥얼거리는 그...
  •  
    1