tomcat配置多个网站多个站点
程序员文章站
2022-06-26 16:22:52
一般一个域名可以设置多个二级域名,然后服务器上可以放多个站点,那在tomcat上如何配置呢?
一般一个域名可以设置多个二级域名,然后服务器上可以放多个站点,那在tomcat上如何配置呢?
<Host name="a.com" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="" docBase="/usr/local/tomcat/apache-tomcat-9.0.24/webapps/testa" 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="test_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
<Host name="b.com" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="" docBase="/usr/local/tomcat/apache-tomcat-9.0.24/webapps/testb" 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="test_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
1、主要是在server.xml中添加多个host节点;
2、host节点中的配置:
name就是所对应绑定的访问域名;
docBase就是网站所访问的文件夹;
遗留问题:配置好站点后,如何设置域名默认访问的网页是什么?比如default.html或是index.html
参考以下网页:https://blog.csdn.net/qq_23853743/article/details/84667110
本文地址:https://blog.csdn.net/jiezhang656/article/details/109253619