发布:2022/3/14 16:46:11作者:管理员 来源:本站 浏览次数:1312
最近想要在tomcat中部署多个网站,但是不知道怎么配置,通过查找资料和摸索,发现要实现这一点其实还是很简单的。
如何利用Tomcat建立多个Web应用 呢?
重点就是:server.xml文件的配置
找到server.xml配置文件中的<Host>节点,通过增加host,来配置多个站点。
配置站点1
<Host name="www.shishangshow.top" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="" docBase="C:\yxy\tomcat\webapps\shishangshow" reloadable="true" >
</Context>
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<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="www.yangxianyang.top" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="" docBase="C:\yxy\tomcat\webapps\yangxianyang" reloadable="true" >
</Context>
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
配置站点3
<Host name="*" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="" docBase="C:\yxy\tomcat\webapps\yangxianyang" reloadable="true" >
</Context>
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
就这样通过增加host就能配置多个站点了,还是挺简单。
© Copyright 2014 - 2024 柏港建站平台 ejk5.com. 渝ICP备16000791号-4