1. 程式人生 > >web tomcat配置多個host例項

web tomcat配置多個host例項

tomcat server.xml配置如下
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">  
       <Context docBase="LuceneAjax" path="/LuceneAjax" reloadable="true"   
              source="org.eclipse.jst.j2ee.server:LuceneAjax"/>
</Host>  
  
  <Host appBase="tempapp" autoDeploy="true" name="yourdomain" unpackWARs="true">  
         <Context docBase="d://yourdir" path="/dir" reloadable="true"   
              source="org.eclipse.jst.j2ee.server:LuceneAjax"/>
 </Host>  


其中appBase是web專案所在的目錄 name是域名 它不是隨便取的 應該在host檔案中配置才能用 或者用你的機器名

開啟C:/WINDOWS/system32/drivers/etc/hosts檔案,在其中增加
127.0.0.1       yourdomain

訪問時:http://yourdomain:port/dir/filename