在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端口是新增的,以后的訪問(wèn)將用到
<Engine name=”second” debug=”0″>
<Host appBase=”F:\virtualhost2″ autoDeploy=”true” name=”site2″ unpackWARs=”true”>
<Context path=”” docBase=”.” debug=”0″ />
</Host>
</Engine>
</Service>
啟動(dòng)tomcat,輸入 http://localhost:8080/index.html—將顯示tomcat/webapps/ROOT/index.html 里邊的內(nèi)容;輸入 http://localhost:8082/index.html—將顯示F:\virtualhost2 下的index.html 里邊的內(nèi)容。
這里通過(guò)不同的端口進(jìn)來(lái)實(shí)現(xiàn)了,不同基于不同端口的虛擬空間的配置。
以上是關(guān)于tomcat怎么配虛擬主機(jī)的知識(shí)分享,西部數(shù)碼網(wǎng)站提供多類(lèi)型、高性?xún)r(jià)的虛擬主機(jī)產(chǎn)品,購(gòu)買(mǎi)鏈接 http://www.ps-sw.cn/services/webhosting/