`

一台电脑上启动两个tomcat方法

 
阅读更多

     由于两个工程分别部署在不同的服务器下,一个用来开发,一个用来测试,需要同时启动两个tomcat,如图apache-tomcat-6.0.35是开发服务器,apache-tomcat6test用来测试:

以下是方法:

1.特别要注意:不要设置CATALINA_HOME 

 

 

2.分别修改安装目录下的conf子目录中的server.xml文件: 

    a.修改http访问端口(默认为8080端口,apache-tomcat-6.0.35改成8091, apache-tomcat6test改成8095),将8080修改为tomcat不在使用的端口号。此处所设的端口号即是以后访问web时所用的端口号。 

    b.修改apache-tomcat-6.0.35的Shutdown端口(在server.xml中,默认为8005端口),将8005修改为没有在使用的端口号,例如8055。  apache-tomcat6test的Shutdown端口(在server.xml中,默认为8005端口),将8005修改为没有在使用的端口号,例如8099。

    c.修改 apache-tomcat6test的8009端口(AJP),将8009修改为没有在使用的端口号,(也在server.xml中修改)例如8010; apache-tomcat-6.0.35的8009端口不改。

(注意:只要是这两个文件中的这三处端口不一样就行,不一定都要进行修改;可以保持一个tomcat的server.xml文件不变,另一个tomcat的server.xml文件与对应的server.xml的端口不一样即可。) 

 

3.依次启动两个tomcat。

 

可以都在eclipse中启动,也可以通过对应的startup.bat启动,还可以一个用elipse启动,另一个通过startup.bat启动。

 

  • apache-tomcat-6.0.35的server.xml如下:

 

 

<?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.
--><!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 --><Server port="8055" shutdown="SHUTDOWN">

  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener"/>
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
  <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container", 
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">
  
    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
        maxThreads="150" minSpareThreads="4"/>
    -->
    
    
    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector connectionTimeout="20000" port="8091" protocol="HTTP/1.1" redirectPort="8443"/>
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />
    -->           
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the 
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->
    <!--
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">         
    --> 
    <Engine defaultHost="localhost" name="Catalina">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->        

      <!-- The request dumper valve dumps useful debugging information about
           the request and response data received and sent by Tomcat.
           Documentation at: /docs/config/valve.html -->
      <!--
      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
      -->

      <!-- This Realm uses the UserDatabase configured in the global JNDI
           resources under the key "UserDatabase".  Any edits
           that are performed against this UserDatabase are immediately
           available for use by the Realm.  -->
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>

      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"  
               prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
        -->

      <Context docBase="operamasks" path="/operamasks" reloadable="true" source="org.eclipse.jst.jee.server:operamasks"/></Host>
    </Engine>
  </Service>
</Server>

 

 

 apache-tomcat6test的server.xml如下:

 

<?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.
-->
<!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 -->
<Server port="8099" shutdown="SHUTDOWN">

  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <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>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container", 
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">
  
    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
        maxThreads="150" minSpareThreads="4"/>
    -->
    
    
    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8095" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />
    -->           
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the 
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->
    <!--
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">         
    --> 
    <Engine name="Catalina" defaultHost="localhost">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->        

      <!-- The request dumper valve dumps useful debugging information about
           the request and response data received and sent by Tomcat.
           Documentation at: /docs/config/valve.html -->
      <!--
      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
      -->

      <!-- This Realm uses the UserDatabase configured in the global JNDI
           resources under the key "UserDatabase".  Any edits
           that are performed against this UserDatabase are immediately
           available for use by the Realm.  -->
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"  
               prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
        -->

      </Host>
    </Engine>
  </Service>
</Server>

 

 

 apache-tomcat-6.0.35启动成功:

 

 

 apache-tomcat6test启动成功:

 

 

 

  • 大小: 7.3 KB
  • 大小: 116.5 KB
  • 大小: 120.6 KB
分享到:
评论

相关推荐

    一台服务器上启动多个tomcat

    - **描述**:“利用不同端口区别,同一台电脑上可启动多个tomcat” 这些信息提示我们本篇文章将会探讨如何在同一台计算机上启动多个Tomcat实例,并通过配置不同的端口号来区分它们。 #### 方法一:使用多个Tomcat...

    一台机器上部署不同版本JDK,两个Tomcat的解决方案

    ### 一台机器上部署不同版本JDK及两个Tomcat实例的解决方案 #### 一、背景介绍 在实际项目开发和运维过程中,有时会遇到需要在同一台机器上部署不同版本的Java Development Kit (JDK) 和多个Apache Tomcat服务器的...

    一台服务器多个tomcat配置

    在命令行下分别进入两个不同的 Tomcat 安装目录下,执行 startup.bat,分别启动两个 Tomcat。然后,在浏览器中输入:http://localhost:8080 和 http://localhost:8090。 七、注意事项 如果 Tomcat 运行异常,出现 ...

    同一服务器部署多个Tomcat方法.docx

    ### 同一服务器部署多个Tomcat的方法 在实际的应用场景中,有时我们可能...通过上述步骤,我们不仅可以在同一台服务器上部署多个Tomcat实例,还可以让它们在系统启动时自动运行,极大地提高了系统的灵活性和可用性。

    在同一台服务器上配置多个Tomcat的方法

    如果在同一台机器上部署多个Tomcat实例,不修改端口会直接导致端口冲突,使得后面的Tomcat实例无法正常启动。因此,修改Tomcat的配置文件是部署多个实例的关键步骤。 按照给定文件中的步骤,配置多个Tomcat实例的...

    配置多台tomcat

    - 在命令行窗口中分别进入两个Tomcat实例的`bin`目录,运行`startup.bat`来启动Tomcat服务。 - 通过浏览器访问`http://localhost:8080`和`http://localhost:8090`来验证是否成功启动。 #### 总结 通过以上步骤,...

    同一台服务器(电脑)运行多个Tomcat的设置方法步骤

    如果一切配置正确,你应该可以在同一台服务器上看到两个Tomcat实例都在正常运行,且互不干扰。 通过这种方法,我们不仅可以充分利用服务器资源,还可以有效地管理和隔离不同应用的服务。这在测试环境、开发环境或...

    tomcat配置入门和配置多个项目

    ### Tomcat配置入门与配置多个项目详解 #### Tomcat简介 ...这种方式非常适合于需要在同一台服务器上部署多个不同Web应用的场景。同时,通过手动配置虚拟目录,还可以更加灵活地管理各个项目的位置与访问路径。

    Tomcat免安装版下载

    2. 自由移动:由于无需在系统注册表中留下信息,免安装版可以方便地在不同电脑间复制或移动,这对于开发者在多台设备上工作非常有利。 3. 空间占用小:相比正式安装版,免安装版通常不包含额外的组件和服务,因此...

    Tomcat目录详解

    1. bin:该目录下存放的是二进制可执行文件,如果是安装版,那么这个目录下会有两个 exe 文件:tomcat6.exe、tomcat6w.exe,前者是在控制台下启动 Tomcat,后者是弹出 UGI 窗口启动 Tomcat;如果是解压版,那么会有...

    zip版本的Tomcat配置

    若希望每次开机都能自动启动Tomcat,需将服务的启动类型更改为“自动”。 #### 四、控制台控制服务的命令 - **启动服务**:在命令行中输入`net start &lt;服务名&gt;`,其中`&lt;服务名&gt;`可以是`SERVICE_NAME`或`PR_DISPLAY...

    tomcat7.0.47-windows-64位,免安装版!

    这两个组件对于Tomcat的正常运行至关重要,因为Tomcat自身依赖于JDK来解释和执行Java代码。 安装JDK和JRE的步骤如下: 1. 下载适合Windows 64位系统的JDK和JRE安装包,可以从Oracle官方网站获取。 2. 安装JDK,...

    Tomcat实现多域名访问详解

    如果需要让Tomcat同时监听80和8080端口,可以配置两个Connector元素。其中80端口用于处理无端口号的HTTP请求,而8080端口则用于处理显式指定端口号的HTTP请求。 Tomcat中的域名与Web应用的绑定是在server.xml文件中...

    启动力企业建站系统 v3.0.zip

    启动力CMS拥有同步搭建企业PC电脑站和手机WAP站功能,实现一个后台管理两个网站,HTML CSS设计,更轻便,具有繁简切换功能,使得网站管理更便捷,为您节约时间,节省建站成本。 全引擎SEO优化 拥有齐全的SEO优化...

    spring集成dubbo分布式系统部署流程包含zookeeper redis nginx.docx

    Spring 集成 Dubbo 分布式系统部署流程是一种常见的微服务架构部署方法,该方法通过结合 Zookeeper、Redis、Nginx 等技术,可以实现高可用、高性能的分布式系统。下面将详细介绍该部署流程中涉及到的知识点: 1. ...

    Java项目开发与毕业设计指导

    两个客户端可以在同一台电脑上运行。 Ch04:多媒体展示系统 –网络游鱼 安装JDK、配置环境变量,打开Eclipse导入ch04项目,运行server.FishServer类启动服务器端,运行java client.SwimFish类启动客户端。注意,...

    XIAOYA安装配置手册_Greenplum_v20161226

    在安装步骤中,手册建议使用两台服务器进行部署,一台作为master节点,另一台作为segment节点,且指定了特定的主机名和IP地址。对于服务器的硬件配置,特别提到了硬盘的扩展和分区,这是Greenplum数据库性能的重要...

Global site tag (gtag.js) - Google Analytics