• 一个tomcat设置多个端口,多个端口对应多个应用


    修改tomcat/conf目录里面server.xml文件

    例如下面这样新增一个8090端口,设置下appBase目录,这样就可以用一个tomcat监听多个端口,每个端口都可以放应用了。我这样新增下面这个配置以后,tomcat就监听了2个端口(8080,8090)

    webapps目录和mywebapps目录的应用都会启动,可以根据不同的端口进行访问里面的应用

    <?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="80" 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 &quot;%r&quot; %s %b" />
    
          </Host>
        </Engine>
      </Service>
      
      <Service name="Catalina2">
     
        <Connector port="81" protocol="HTTP/1.1"
                   connectionTimeout="20000"
                   redirectPort="8445" />
         
        <Connector port="8010" protocol="AJP/1.3" 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 &quot;%r&quot; %s %b" />
    
          </Host>
        </Engine>
      </Service>
    </Server>

    把项目war包改名为ROOT放进appBase属性指定的路径下启动服务即可。

    来自:https://www.cnblogs.com/ClassNotFoundException/p/6489390.html

  • 相关阅读:
    Python全栈day28(描述符应用)
    Python全栈day28(上下文管理)
    如何在B2C电子商务网站后台添加CNZZ统计代码(转)
    数据统计以及商城运营日志在电子商务中的重要性(转)
    电商企业运营规划——五年经验总结(转)
    电子商务数据运营入门——有哪些数据分析需要做 (转)
    IDC单IP绑定多域名(包括端口)
    商城自动备份
    CentOS安装crontab及使用方法(转)
    CentOS中使用Shell脚本实现每天自动备份网站文件和数据库并上传到FTP中(转)
  • 原文地址:https://www.cnblogs.com/luck666/p/10531952.html
Copyright © 2020-2023  润新知