当前位置: 代码迷 >> Java Web开发 >> 关于Tomcat 7绑定域名的有关问题
  详细解决方案

关于Tomcat 7绑定域名的有关问题

热度:3357   发布时间:2013-02-25 21:09:52.0
关于Tomcat 7绑定域名的问题
有NN个网站 N个域名放在同一台服务器上

我想绑定www.xxx.com的域名,并把它指定webapps/xxx

我找了一些资料, 但是都没成功

(先声明, tomcat配置好了, http://localhost:8080可以访问到默认页)

就拿更改local为例吧, 把localhost由默认的webapps/ROOT指向为webapps/test_localhost, test_localhost下有一index

下面是默认的Tomcat7配置

<Host name="localhost" appBase="webapps"
  unpackWARs="true" autoDeploy="true">
  <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" resolveHosts="false"/>
 </Host>

我将它改为

<Host name="localhost" appBase="webapps/test_localhost"
  unpackWARs="true" autoDeploy="true">
  <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" resolveHosts="false"/>
 </Host>

QUESTION 1:访问http://localhost:8080 看以失败页面! 这样设置不对吗? appBase 应该如何写?



于是我一气之下,恢复了默认的appBase后, 直接把项目copy到了webapps/ROOT里面, 然后重启tomcat,输入http://localhost:8080

结果...访问失败!

我输入http://localhost:8080/index 竟然访问成功!

我看了一下web.xml中有这样的配置,默认的都没变
<welcome-file-list>
  <welcome-file>index</welcome-file>
  <welcome-file>index.htm</welcome-file>
  <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

QUESTION 2:为什么会http://localhost:8080访问不到呢?

------解决方案--------------------------------------------------------
我也遇到了这样的问题,关注……
  相关解决方案