Tomcat服務器配置,二級域名,域名訪問

我要做:

  1. 通過域名訪問網站

  2. 設置二級域名,用來訪問webapps下不同的項目。

  3. 設置域名默認訪問的項目

能解決問題:

  1. 阿里雲/騰訊雲,通過域名訪問網站

  2. 二級域名設置

  3. 默認項目設置

  4. 連接到遠程服務器不成功問題

  5. 域名解析問題

ps : 以上問題在問題解決中都有涉及,如果還有問題,請私我

問題一:域名解析問題

在阿里雲/騰訊雲中的域名管理中進行域名解析。

按照它的要求填入域名解析規則。@、www、*等等。域名解析所指向爲你的外網ip地址。

此時在本地電腦dos界面上輸入:ping www.sss.com(sss爲你的域名,請修改)

如果能ping通,說明域名解析ok。(dos界面自己百度)

ps : 如果不通,請直接在dos界面中輸入:ping 115.214.214.01 (此處是你的外網ip)

問題二:二級域名設置

進入遠程服務器,方式可以通過遠程連接或者其他。

在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" />
        -->

        <!-- 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 &quot;%r&quot; %s %b" />
    <Context path="" docBase="C:\Program Files\apache-tomcat-7.0.69\webapps\SHstrutshib"  reloadable="true" caseSensitive="false" debug="0"></Context>
      </Host>



      <!-- manger -->
      <Host name="manager.mark.me" debug="0" appBase=""
        unpackWARs="true" 
        xmlValidation="false" xmlNamespaceAware="false">

         <Alias>manager.mark.me</Alias>

        <Context path="" docBase="C:\Program Files\apache-tomcat-7.0.69\webapps\manager"  reloadable="true" caseSensitive="false" debug="0"></Context>
      </Host>

      <Host name="sh.mark.me" debug="0" appBase=""
        unpackWARs="true" 
        xmlValidation="false" xmlNamespaceAware="false">

         <Alias>sh.mark.me</Alias>

        <Context path="" docBase="C:\Program Files\apache-tomcat-7.0.69\webapps\SHstrutshib"  reloadable="true" caseSensitive="false" debug="0"></Context>
      </Host>123456789101112131415161718192021222324252627282930313233343536373839123456789101112131415161718192021222324252627282930313233343536373839

同時將端口設置成:80 。設置80是在瀏覽器中不設置www.xxx.com:8080/端口訪問,直接www.xxx.com訪問

    <Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />123123

如果所有的這些配置成功表示:

你可以在電腦上通過輸入以下域名訪問不同項目:

sh.mark.me 訪問webapps中的SHstrutshib項目

manager.mark.me 訪問webapps中的manager項目

問題三、配置域名默認項目,即不顯示tomcat的主界面

在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" />
        -->

        <!-- 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 &quot;%r&quot; %s %b" />
    <Context path="" docBase="C:\Program Files\apache-tomcat-7.0.69\webapps\SHstrutshib"  reloadable="true" caseSensitive="false" debug="0"></Context>
      </Host>12345678910111213141516171234567891011121314151617

這是每一個tomcat都默認自帶的一個host,所以只要在其中加入一條:

<Context path="" docBase="C:\Program Files\apache-tomcat-7.0.69\webapps\SHstrutshib"  reloadable="true" caseSensitive="false" debug="0"></Context>11

就可以做到訪問域名www.mark.me直接訪問SHstrutshib項目


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章