TOMCAT类似iis主机头配置方法

来源:互联网 发布:java中格式化时间毫秒 编辑:程序博客网 时间:2024/03/29 18:38

测试过程:
   
系统:windowsxp
    C:/WINDOWS/system32/drivers/etc/hosts
文件 添加
   127.0.0.1       www.hi.com
   127.0.0.1       www.hello.com
这样可以测试www.hi.comwww.hello.com两个域名指向本地服务器。


1.
若要使tomcat使用80端口,确保80端口可用
2.
修改tomcat conf/server.xml
 <Connector port="8080" ==> <Connector port="80"
3. <Engine name="Catalina" defaultHost="localhost">
 
添加<Host name="www.hi.com" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context path="" docBase="D:/tomcat-6.0.16/1webapps/jforum" debug="0" reloadable="true"/>
</Host>

<Host name="www.hello.com" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context path="" docBase="E:/eclipse/ws/pm/WebContent" debug="0" reloadable="true"/>
</Host>


其中D:/tomcat-6.0.16/1webapps/jforumE:/eclipse/ws/pm/WebContent2web应用程序

这样 D:/tomcat-6.0.16/1webapps/jforum对应的web应用使用http://www.hi.com访问
这样 E:/eclipse/ws/pm/WebContent对应的web应用使用http://www.hello.com访问

测试通过

 

===============================================================================================
http://dg.lawyer.com
的配置
conf/server.xml
中添加:
<Host name="dg......com" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context path="" docBase="dgpx
系统的目录" debug="0" reloadable="true"/>
</Host>