서버환경 :
Windows Server 2016 64bit
JDK가 설치되어 있어야 한다.
1. 톰캣 다운로드
http://tomcat.apache.org
64-bit Windows zip 을 다운로드 받는다.
2. 압축풀어서 적당한 곳에 위치시킨다.
C:\Program Files\Apache Software Foundation 폴더에
apache-tomcat-8.0.531
apache-tomcat-8.0.532
와 같이 다른 이름으로 압축을 풀어준다.
현재로선 두 폴더의 내용은 동일하다.
3. 첫번째 서버 포트를 구성한다.
3.1 server.xml를 수정한다.
apache-tomcat-8.0.531/conf/server.xml
수정할 부분은 아래와 같다.(빨간색)
서버2와 중복되지 않는 것으로 설정한다.
테스트이므로 서버1은 톰캣 기본 설정 그대로 둔다.
<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<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="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" 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">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>
3.2 startup.bat 파일을 수정한다.
apache-tomcat-8.0.531/bin/startup.bat
아래 빨간색과 같이 추가해 준다.
@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
rem ---------------------------------------------------------------------------
rem Start script for the CATALINA Server
rem ---------------------------------------------------------------------------
set "CATALINA_HOME=C:\Program Files\Apache Software Foundation\apache-tomcat-8.0.531"
set "CATALINA_BASE=C:\Program Files\Apache Software Foundation\apache-tomcat-8.0.531"
set "SERVER_NAME=Server1"
set "JAVA_HOME=C:\Program Files\Java\jdk1.8.0_191"
setlocal
3.3 shutdown.bat 파일을 수정한다.
apache-tomcat-8.0.531/bin/shutdown.bat
startup.bat 파일과 마찬가지로 아래처럼 추가해 준다.
@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
rem ---------------------------------------------------------------------------
rem Stop script for the CATALINA Server
rem ---------------------------------------------------------------------------
set "CATALINA_HOME=C:\Program Files\Apache Software Foundation\apache-tomcat-8.0.531"
set "CATALINA_BASE=C:\Program Files\Apache Software Foundation\apache-tomcat-8.0.531"
set "SERVER_NAME=Server1"
set "JAVA_HOME=C:\Program Files\Java\jdk1.8.0_191"
setlocal
3.4 service.bat 파일을 수정한다.
apache-tomcat-8.0.531/bin/service.bat
80줄 근처의 아래 항목을 찾아서 변경해 준다.
rem Set default Service name
set SERVICE_NAME=Tomcat81
set DISPLAYNAME=Apache Tomcat 8.0 %SERVICE_NAME% Server1
서비스에 등록한다.
4. 두번째 서버 포트를 구성한다.
4.1 server.xml를 수정한다.
apache-tomcat-8.0.532/conf/server.xml
수정할 부분은 아래와 같다.(빨간색)
서버1과 중복되지 않는 것으로 설정한다.
<?xml version='1.0' encoding='utf-8'?>
<Server port="9005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<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="Catalina">
<Connector port="9080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="9443" />
<Connector port="9009" protocol="AJP/1.3" redirectPort="9443" />
<Engine name="Catalina" 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">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>
4.2 startup.bat 파일을 수정한다.
apache-tomcat-8.0.532/bin/startup.bat
아래 빨간색과 같이 추가해 준다.
@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
rem ---------------------------------------------------------------------------
rem Start script for the CATALINA Server
rem ---------------------------------------------------------------------------
set "CATALINA_HOME=C:\Program Files\Apache Software Foundation\apache-tomcat-8.0.532"
set "CATALINA_BASE=C:\Program Files\Apache Software Foundation\apache-tomcat-8.0.532"
set "SERVER_NAME=Server2"
set "JAVA_HOME=C:\Program Files\Java\jdk1.8.0_191"
setlocal
4.3 shutdown.bat 파일을 수정한다.
apache-tomcat-8.0.532/bin/shutdown.bat
startup.bat 파일과 마찬가지로 아래처럼 추가해 준다.
@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
rem ---------------------------------------------------------------------------
rem Stop script for the CATALINA Server
rem ---------------------------------------------------------------------------
set "CATALINA_HOME=C:\Program Files\Apache Software Foundation\apache-tomcat-8.0.532"
set "CATALINA_BASE=C:\Program Files\Apache Software Foundation\apache-tomcat-8.0.532"
set "SERVER_NAME=Server2"
set "JAVA_HOME=C:\Program Files\Java\jdk1.8.0_191"
setlocal
3.4 service.bat 파일을 수정한다.
apache-tomcat-8.0.531/bin/service.bat
80줄 근처의 아래 항목을 찾아서 변경해 준다.
rem Set default Service name
set SERVICE_NAME=Tomcat82
set DISPLAYNAME=Apache Tomcat 8.0 %SERVICE_NAME% Server2
서비스에 등록한다.
5. 서버1, 서버2를 시작한다.
작업관리자 > 서비스 항목에 간다.
Tomcat81, Tomcat82 항목을 찾아 마우스 우측 클릭 > 시작을 클릭한다.
6. 브라우저에서 접속해 본다.
8080, 9080 동일하게 나올 것이다.
끝.