개발

[was][tomcat] 톰켓 2개의 웹사이트 구동

지승준 2014. 9. 24. 16:33

경로 : Tomcat 7.0\conf\server.xml


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?xml version="1.0" encoding="utf-8"?>
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <Listener className="org.apache.catalina.core.JasperListener" />  
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
 
  <GlobalNamingResources>
    <Resource 
      name="UserDatabase" 
      auth="Container"
      type="org.apache.catalina.UserDatabase"
      description="User database that can be updated and saved"
      factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
      pathname="conf/tomcat-users.xml" 
    />
  </GlobalNamingResources>
 
  <Service name="web1">
    <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" 
      useBodyEncodingForURI="true" URIEncoding="utf-8" />
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    <Engine name="web1" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
       <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
      </Realm>
      <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">      
        <Context path="" docBase="e:\webApp\web1" reloadable="true"/>
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." 
          suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />      
      </Host>
    </Engine>
  </Service>
 
  <Service name="web2">
    <Connector port="8082" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8444" 
      useBodyEncodingForURI="true" URIEncoding="utf-8" />
    <Connector port="8010" protocol="AJP/1.3" redirectPort="8444" />
    <Engine name="web2" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
       <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
      </Realm>
      <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">      
        <Context path="" docBase="e:\webApp\web2" reloadable="true"/>
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." 
          suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />      
      </Host>
    </Engine>
  </Service>
</Server>
cs


1. 강조된 부분 변경

2. 윈도우 방화벽에서 사용된 포트 허용 규칙추가


※ server.xml 참고 설명

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!-- service는 독립적인 톰캣의 서비스 이다. -->
<Service name="web1"></Service>
 
<!-- Connector Client와 요청을 주고 응답을 받는 Interface이다. -->
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" 
useBodyEncodingForURI="true" URIEncoding="utf-8" />
 
<!-- Apache Jserv Protocol -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
 
<!-- Engine은 적절한 Host로 처리를 넘기는 역할을 한다. -->
<Engine name="web1" defaultHost="localhost"></Engine>
 
<!-- Realm, Valve Component를 이용하면 Database연결, Single Sing On, Access Log등 부가기능을 
이용 할 수 있다. -->
<Realm className="org.apache.catalina.realm.LockOutRealm"></Realm>
 
<!-- 가상 호스트를 정의한다. -->
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"></Host>
 
<!-- 가상호스트에서 동작하는 하나의 웹 어플리케이션 이다. -->
<Context path="" docBase="e:\webApp\web1" reloadable="true"/>
cs