在tomcat/service.xml 里半加入一段 <Service> 配置,如下
<Service>
<Connector ……./>
<Engine defaultHost=”localhost” name=”Catalina” >
…….
</Engine>
</Service> 這里的配置也是文件原本就有的,下面是增加的。
<Service>
<Connector connectionTimeout=”20000″ port=”8082″ protocol=”HTTP/1.1″ redirectPort=”8443″/> 因?yàn)槭腔诙丝诘呐渲?,這里的8082端口是新增的,以后的訪問將用到
<Engine name=”second” debug=”0″>
<Host appBase=”F:\virtualhost2″ autoDeploy=”true” name=”site2″ unpackWARs=”true”>
<Context path=”” docBase=”.” debug=”0″ />
</Host>
</Engine>
</Service>
啟動tomcat,輸入 http://localhost:8080/index.html—將顯示tomcat/webapps/ROOT/index.html 里邊的內(nèi)容;輸入 http://localhost:8082/index.html—將顯示F:\virtualhost2 下的index.html 里邊的內(nèi)容。
這里通過不同的端口進(jìn)來實(shí)現(xiàn)了,不同基于不同端口的虛擬空間的配置。
以上是關(guān)于tomcat怎么配虛擬主機(jī)的知識分享,西部數(shù)碼網(wǎng)站提供多類型、高性價(jià)的虛擬主機(jī)產(chǎn)品,購買鏈接 http://bingfeng168.cn/services/webhosting/