<?xml version="1.0" encoding="UTF-8"?>
<Server port="8885" 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>
<!--配置1 实现不同域名访问 00000000000000000000000000 -->
<!-- 更改service实现同一个端口不同域名访问不同网站 网站端口为8080 -->
<Service name="Catalina">
<!-- 更改访问的端口 8080 如果是小于1024端口则需要用root用户启动 否则启动不了 -->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8889" 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>
<!-- 域名1 添加host 更改name为域名地址 实现不同域名访问不同的网站-->
<Host name="web1.localdomain" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- 添加下面一行代码 添加访问的文件夹目录 如果在webapps目录下直接写如果不在则需要绝对路径 -->
<Context path="" debug="0" docBase="/home/wen/tomcat/tomcat8/webapps/web1" reloadable="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>
<!-- 域名2 添加host 更改name为域名地址 实现不同域名访问不同的网站 -->
<Host name="web2.localdomain" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!--网站的路径 -->
<Context path="" debug="0" docBase="/home/wen/tomcat/tomcat8/webapps/web4" reloadable="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>
<!-- 配置2 实现不同端口访问 00000000000000000000000000000000 -->
<!-- 添加service 实现不同端口访问不同网站 -->
<Service name="form2">
<!-- 第二个网站的端口 -->
<Connector port="8090" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8889" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="form2" defaultHost="localhost"> <!-- name要与service的name相同一致 -->
<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">
<!--添加第二个网站的路径 -->
<Context path="" debug="0" docBase="/home/wen/tomcat/tomcat8/webapps/web2" reloadable="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>
<!-- 添加service 实现不同端口访问不同网站 -->
<Service name="form3">
<!-- 第3个网站的端口 -->
<Connector port="9000" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8889" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="form3" 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">
<!--添加第3个网站的路径 -->
<Context path="" debug="0" docBase="/home/wen/tomcat/tomcat8/webapps/web3" reloadable="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>
<!-- 00000000000000000000000000000000000000000 -->
</Server>