serve.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.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="www.a.com" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- <Context docBase="app1" path="/app1" reloadable="true" /> --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs/1" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> <Host name="www.b.com" appBase="webapps2" unpackWARs="true" autoDeploy="true"> <!-- <Context docBase="app2" path="" reloadable="true" /> --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs/2" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> <!-- 修改的地方 --> </Engine> </Service> </Server>
细心的你可以发现:
只有Host里面的东西改了一下。新增或修改的内容如下:
<Host name="www.a.com" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- <Context docBase="app1" path="/app1" reloadable="true" /> --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs/1" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> <Host name="www.b.com" appBase="webapps2" unpackWARs="true" autoDeploy="true"> <!-- <Context docBase="app2" path="" reloadable="true" /> --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs/2" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host>
里面多了一个webapps2
,我们要在tomcat目录下把原来的webapps复制一下,改名成为webapps2,就行。
记得阿里云控制台要把你要用的端口开放。
尝试2:
最后对xml不熟悉的我,用了如下麻烦的方法:
<Host name="a.com" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- <Context docBase="app1" path="/app1" reloadable="true" /> --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs/1" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> <Host name="www.a.com" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- <Context docBase="app1" path="/app1" reloadable="true" /> --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs/1" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> <Host name="b.com" appBase="webapps2" unpackWARs="true" autoDeploy="true"> <!-- <Context docBase="app2" path="" reloadable="true" /> --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs/2" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> <Host name="www.b.com" appBase="webapps2" unpackWARs="true" autoDeploy="true"> <!-- <Context docBase="app2" path="" reloadable="true" /> --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs/2" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host>
标签:xml,Tomcat,--,端口,webapps2,域名 From: https://www.cnblogs.com/Fooo/p/17061187.html