今天学了一些Tomcat的使用:
首先配置一个临时域名:找到路径:C:\Windows\System32\drivers\etc中的hosts文件,然后在最后一行加入:
127.0.0.1 localhost
127.0.0.1 yiquanchaoren //这里随便取什么名字,这个就是新域名了
然后就是配置下虚拟主机:
在tomcat中的conf目录下的server.xml中加入:
host里面的name是指新的域名(也就是主机名),
<Engine name="Catalina" defaultHost="localhost">
<Host name="yiquanchaoren" appBase="F:\tomcatTest">
<Context path="/tomcatTest" docBase="F:\tomcatTest"/>
</Host>
再接着讲端口从8080改为80:在server.xml中改
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
最后在文档中的WEB-INF中添加web.xml文件,拷贝ROOT中的代码,在最后加入:
<welcome-file-list>
<welcome-file>test.html</welcome-file>
</welcome-file-list>
这句话将test.html设置成了网站首页
这个时候在网页中输入http://yiquanchaoren/tomcatTest就可以访问到test.html这个网页了