tomcat部署多网站

把目录复制到webapps下,即可自动发布

 

修改conf/server.xml,增加不同的Service节即可,不同的端口发布不同的网站,也可多个端口发布同一个网站:

<Service name="Catalina1">
<Connector connectionTimeout="20000" port="8099" protocol="HTTP/1.1" redirectPort="8443"/>

<Engine defaultHost="localhost" name="Catalina1">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
<Host appBase="webapps1" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">
</Host>
</Engine>
</Service>

<Service name="Catalina2">
<Connector connectionTimeout="20000" port="8098" protocol="HTTP/1.1" redirectPort="8443"/>
<Engine defaultHost="localhost" name="Catalina2">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
<Host appBase="webapps2" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">
<Context path="" docBase="C:\apache-tomcat-8.5.81\webapps2\ttt" reloadable="true" workDir="C:\apache-tomcat-8.5.81\webapps2\ttt" />
</Host>
</Engine>
</Service>

<Service name="Catalina3">
<Connector connectionTimeout="20000" port="8097" protocol="HTTP/1.1" redirectPort="8443"/>
<Engine defaultHost="localhost" name="Catalina3">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">
<Context path="" docBase="C:\apache-tomcat-8.5.81\webapps2\ttt" reloadable="true" workDir="C:\apache-tomcat-8.5.81\webapps2\ttt" />
</Host>
</Engine>

 

各Service Name要不相同

appBase可以相同,即根目录,但需要在docBase中指定项目的目录位置

 

posted @ 2022-08-09 11:06  81  阅读(182)  评论(0编辑  收藏  举报