一个tomcat配置多个不同端口的项目

1、将要同时启动的项目放入不同的webapps文件夹中

 

 

 2、修改tomcat安装目录下的conf-->server.xml文件,在文件的最后面添加以下内容

 

 

<!-- 第二个项目,webapps1,端口号8081
       再修改redirectPort:8444、
             appBase="webapps1"
  -->
  <Service name="Catalina">
    <Connector port="8081" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8444" />
    <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="webapps1" 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>
  
  <!-- 第三个项目,webapps2,端口号8082
       再修改redirectPort:8445、
             appBase="webapps2"
  -->
  <Service name="Catalina">
    <Connector port="8082" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8445" />
    <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="webapps2" 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>

  

 

posted on 2020-08-18 11:42  lpq22221314  阅读(337)  评论(0编辑  收藏  举报

导航