tomcat 发布多个web项目(多个域名,同一ip)

公司有个项目,需要在同一个Tomcat服务器上,部署多个应用,这样,就是一个IP地址对应不同的web项目。


    在tomcat的conf目录修改server.xml配置域名和项目的挂接关系可以注释掉默认<host></host>
使用实际用到的配置路径:
<Host name="www.google.cn" debug="0" appBase="webapps"
         unpackWARs="true"  xmlValidation="false" xmlNamespaceAware="false">
         <Context path="" docBase="D:\Tomcat5\webapps\host1"  reloadable="true"   caseSensitive="false"   debug="0"></Context>
  </Host>

 
<Host name="www.youku.com" debug="0" appBase="webapps"
  unpackWARs="true" xmlValidation="false" xmlNamespaceAware="false"> 
        <Context path="" docBase="D:\Tomcat5\webapps\host2" reloadable="true"   caseSensitive="false"   debug="0"></Context>
</Host>

      其中:Host 的name属性为你的域名、appBase指向你的工程文件所在的目录、docBase指向你的工程目录,其他属性可根据自己实际情况及需要配置。

      不配置<Context path="" docBase="D:\Tomcat5\webapps\host1"  reloadable="true"   caseSensitive="false"   debug="0"></Context>的话,tomcat会将\webapps\ROOT作为docBase的路径。

       配置完成后到检查web.xml检查是否有:

"<welcome-file-list id="WelcomeFileList">
  <welcome-file>index.html</welcome-file>
  <welcome-file>index.jsp</welcome-file>
</welcome-file-list>"

然后到docBase指定的目录下增加index.html文件,内容是:

<%@ page contentType="text/html; charset=GBK" %>

<script type="text/javascript">

window.location.href="/ecdomain/framework/qhdwmn/index.jsp";
</script>

保存后重启tomcat即可。

猜你喜欢

转载自hrf472989050.iteye.com/blog/1808939