zoukankan      html  css  js  c++  java
  • Tomcat域名绑定

    域名绑定与虚拟目录设置: 
    conf/server.xml 的修改方式如下:

    单个域名绑定: 
    原始: 

    <Engine name="Catalina" defaultHost="localhost"> 
    <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false" /> 
    </Engine> 

    当然这里我把注释代码统统删除掉了,省的碍眼 

    修改后:

    <Host name="chengqun.202.71one.com" debug="0" appBase="d:wwwrootchengqun" 
    unpackWARs="true" autoDeploy="true" 
    xmlValidation="false" xmlNamespaceAware="false"> 
    <Context path="/" docBase="d:wwwrootchengqun"></Context> 
    </Host> 
    <Host name="chengqun1.202.71one.com" debug="0" appBase="d:wwwrootchengqun1" 
    unpackWARs="true" autoDeploy="true" 
    xmlValidation="false" xmlNamespaceAware="false"> 
    <Context path="/" docBase="d:wwwrootchengqun1"></Context> 
    </Host>

    多域名绑定:

    <Host name="chengqun.202.71one.com" debug="0" appBase="d:wwwrootchengqun" 
    unpackWARs="true" autoDeploy="true" 
    xmlValidation="false" xmlNamespaceAware="false"> 
    <Alias>chengqun.202.71one.com</Alias> 
    <Alias>chengqun1.202.71one.com</Alias> 
    <Alias>chengqun2.202.71one.com</Alias> 
    <Context path="/" docBase="d:wwwrootchengqun"></Context> 
    </Host> 

    这里面的参数还有很多,我也不是很清楚,不过这样做确实可以实现多域名绑定哈哈.而且网站页面修改了只要直接覆盖就可以了,tomcat可以自动更新类和页面,当然如果修改了web.xml或lib,则需要重启tomcat才可以.

    (二)虚拟目录

    <Host name="chengqun.202.71one.com" debug="0" appBase="d:wwwrootchengqun" 
    unpackWARs="true" autoDeploy="true" 
    xmlValidation="false" xmlNamespaceAware="false"> 
    <Context path="/chengqun" docBase="d:wwwrootchengqun"></Context> 
    </Host> 

    其中,Host标记是用来配置虚拟主机的,就是可以多个域名指向一个tomcat,格式只要参考默认的就 可以了。 
    <context>是Host标记的子元素吧,表示一个虚拟目录,它主要有两个属性,path就相当于虚拟目录名字, 
    而 docbase则是具体的文件位置。在这里我的虚拟路径名称为chengqun,实际上我的程序也就是html、jsp、servlet都 放在了d:wwwrootchengqun这个目录下了。 
    这样我就可以通过 chengqun.202. com/chengqun 访问我的这个虚拟目录了。

    另外一种方法是:

    <Host name="chengqun.202. com" debug="0" appBase="d:wwwrootchengqun" 
    unpackWARs="true" autoDeploy="true" 
    xmlValidation="false" xmlNamespaceAware="false"> 
    <Context path="/" docBase="d:wwwrootchengqun"></Context> 
    </Host>

    这样设置以后,输入域名可以访问这个站点程序了(Context path="/"这里不同)

    没有指定默认站点,所以直接输入IP的时候,无法访问。如何让输入ip就可以访问指定的站点呢? 
    修改server.xml的 <Engine name="Catalina" defaultHost="chengqun.202. com"> 
    这样就可以实现了输入ip访问chengqun.202. com这个站点的程序了!

  • 相关阅读:
    Scala实验二——3.统计学生成绩
    Scala实验二——2.模拟图形绘制
    Scala实验二——1.计算级数
    Scala类和对象笔记
    《能力陷阱》反思
    spark学习
    Ajax获取后台Servlet数据
    在进行pip安装时报错:Could not fetch URL https://pypi.org/simple/xrld/: There was a problem confirming the ssl certificate:
    pycharm连接服务器的内部环境时出错,输入用户密码之后报错:Permission denied, please try again authentication failed
    pycharm连接docker服务器遇到的错误:java.net.ConnectException: Connection refused
  • 原文地址:https://www.cnblogs.com/younggun/p/3351193.html
Copyright © 2011-2022 走看看