Tomcat 多域名绑定、Tomcat 设置默认项目解析

哈哈 阅读:208 2021-03-31 21:44:50 评论:0

1、查看Tomcat安装目录下conf/server.xml  默认绑定

   <Host name="localhost"  appBase="webapps" 
            unpackWARs="true" autoDeploy="true"> 
 
        <!-- SingleSignOn valve, share authentication between web applications 
             Documentation at: /docs/config/valve.html --> 
        <!-- 
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> 
        --> 
        <!--      <Context path="" docBase="/usr/local/tomcat/webapps/XClode" reloadable="true"/>  --> 
        <!-- 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> 
 注意:以上配置代码的含义是,如果用户在浏览器输入服务器地址+tomcat端口,将会访问webapps页面下的ROOT项目。

              比如:http://localhost:8080/       我们将看到如下界面:待补充


2、tomcat 域名地址绑定操作,操作的主要文件(conf/server.xml)

单独域名绑定:

 <<span style="color:#ff0000;">Host name="xcloudlink.org"</span>  appBase="webapps" 
            unpackWARs="true" autoDeploy="true"> 
 
        <!-- SingleSignOn valve, share authentication between web applications 
             Documentation at: /docs/config/valve.html --> 
        <!-- 
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> 
        --> 
       <span style="color:#ff0000;">  <Context path="" docBase="/usr/local/tomcat/webapps/XClode" reloadable="true"/></span> 
        <!-- 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> 
注意:以上用红线标记的代码,是tomcat 域名绑定的重点:Host :代表域名名称,      Context :代表绑定项目的访问地址


多个域名绑定:其本质是多个单独域名的组合

实例:

<<span style="color:#ff0000;">Host name="xcloudlink.org"</span>  appBase="webapps" 
            unpackWARs="true" autoDeploy="true"> 
 
        <!-- SingleSignOn valve, share authentication between web applications 
             Documentation at: /docs/config/valve.html --> 
        <!-- 
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> 
        --> 
        <span style="color:#ff0000;"> <Context path="" docBase="/usr/local/tomcat/webapps/XClode" reloadable="true"/></span> 
        <!-- 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> 
      <<span style="color:#ff0000;">Host name="icloudlink.cn" </span> appBase="webapps" 
            unpackWARs="true" autoDeploy="true"> 
 
        <!-- SingleSignOn valve, share authentication between web applications 
             Documentation at: /docs/config/valve.html --> 
        <!-- 
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> 
        --> 
         <span style="color:#ff0000;"><Context path="" docBase="/usr/local/tomcat/webapps/XClode" reloadable="true"/></span> 
        <!-- 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> 
     <<span style="color:#ff0000;">Host name="xcloudlink.cn" </span> appBase="webapps" 
            unpackWARs="true" autoDeploy="true"> 
   
        <!-- SingleSignOn valve, share authentication between web applications 
             Documentation at: /docs/config/valve.html --> 
        <!-- 
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> 
        --> 
         <span style="color:#ff0000;"><Context path="" docBase="/usr/local/tomcat/webapps/XClode" reloadable="true"/></span> 
        <!-- 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> 
      <<span style="color:#ff0000;">Host name="xcloudlink.com"</span>  appBase="webapps" 
            unpackWARs="true" autoDeploy="true"> 
   
        <!-- SingleSignOn valve, share authentication between web applications 
             Documentation at: /docs/config/valve.html --> 
        <!-- 
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> 
        --> 
        <span style="color:#ff0000;"> <Context path="" docBase="/usr/local/tomcat/webapps/XClode" reloadable="true"/></span> 
        <!-- 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> 
       <<span style="color:#ff0000;">Host name="youzaiyun.cn"</span>  appBase="webapps" 
            unpackWARs="true" autoDeploy="true"> 
   
        <!-- SingleSignOn valve, share authentication between web applications 
             Documentation at: /docs/config/valve.html --> 
        <!-- 
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> 
        --> 
       <span style="color:#ff0000;">  <Context path="" docBase="/usr/local/tomcat/webapps/XClode" reloadable="true"/></span> 
        <!-- 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> 
	  <<span style="color:#ff0000;">Host name="youzaiyun.com" </span> appBase="webapps" 
            unpackWARs="true" autoDeploy="true"> 
   
        <!-- SingleSignOn valve, share authentication between web applications 
             Documentation at: /docs/config/valve.html --> 
        <!-- 
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> 
        --> 
         <span style="color:#ff0000;"><Context path="" docBase="/usr/local/tomcat/webapps/XClode" reloadable="true"/></span> 
        <!-- 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、设置Tomcat 默认项目

      (1)、将原有ROOT文件夹下的所有内容移除。

(2)、将相关项目已经编译好的文件,存放到ROOT文件夹下。

      (3)、启动tomcat ,输入访问地址:http://localhost:8080/



声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

发表评论
搜索
排行榜
KIKK导航

KIKK导航

关注我们