通過Apache Tomcat創(chuàng)建虛擬主機
一. 打開conf/Server.xml
在Engine中增加一行
<Host name="test.cn" appBase="F:\java\apache-tomcat-9.0.29\webapps\test.cn" autoDeploy="true" >
</Host>
二. 在C:\Windows\System32\drivers\etc\hosts中增加一行
127.0.0.1 test.cn
三. 在F:\java\apache-tomcat-9.0.29\webapps\test.cn中創(chuàng)建ROOT文件夾
然后在下面建立index.jsp文件
內(nèi)容如下:
<%@ page session="false" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> 歡迎歸來! </body> </html>
四. 啟動Tomcat, bin/startup.bat
五. 瀏覽器訪問:test.cn 顯示如下