直接上码,tomcat/conf/server.xml配置如下:

<?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.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="Catalina">



    <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="443" URLEncoding="utf-8"/> 

    <Engine name="Catalina" defaultHost="www.lyitong.com">

      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

      <Host name="www.lyitong.com"  appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> 
            <Context path="" docBase="/usr/local/tomcat/webapps/lyitong/"/> 

        <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>

      <Context path ="" docBase="/"  debug="0" reload ="true"/>
      <Host name="m.lyitong.com" appBase="webapps1" unpackWARs="true" autpDeploy="true">


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

注:记得把tomcat/webapps下的这几个系统默认的文件夹删除以免冲突:

这里写图片描述

配置好后基本可用了,如果还有别的默认页面,可以继续加context标签和相似的配置即可

Logo

更多推荐