Tomcat服务器配置,二级域名,域名访问

来源:互联网 发布:淘宝如何设计水印图 编辑:程序博客网 时间:2024/05/16 06:01

我要做:

  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>

同时将端口设置成:80 。设置80是在浏览器中不设置www.xxx.com:8080/端口访问,直接www.xxx.com访问

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

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

你可以在电脑上通过输入以下域名访问不同项目:

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>

这是每一个tomcat都默认自带的一个host,所以只要在其中加入一条:

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

就可以做到访问域名www.mark.me直接访问SHstrutshib项目

0 0
原创粉丝点击