在<Engine>
元素中添加一个<Host name="" appBase="" unparkWARs="" autoDeploy="" />
,其中:
? name
:指定主机的名称
? appBase
:当前主机的应用发布目录
? unparkWARs
:启动时是否自动解压war包
? autoDeploy
:是否自动发布
配置示例如下:
<Host name="www.itcast.cn" appBase="D:\itcastapps" unpackWARs="true" autoDeploy="true"/>
<Host name="www.itheima.com" appBase="D:\itheimaapps" unpackWARs="true" autoDeploy="true"/>
配置默认端口
Tomcat服务器主配置文件中配置着访问端口,它在配置文件中写的值是:8080。但是它不是Tomcat的默认端口。我们此处说的默认端口是,当使用默认值的时候,端口号可以省略。Tomcat的默认端口是80。
配置方式如下:
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
配置默认应用
有两种方式配置默认应用。
第一种:把要作为默认应用的应用,名称改为ROOT
。放到webapps
目录中。
第二种:写一个独立的配置文件,文件名称为ROOT.xml
。
? 注意:ROOT
必须大写。当使用了独立的ROOT.xml
文件时,webapps
下ROOT
应用就不是默认应用了。
配置默认主页
首先要明确的是,配置默认主页是针对应用说的。是应用的默认主页。
在应用的web.xml中配置:
<welcome-file-list>
<welcome-file>默认主页</welcome-file>
</welcome-file-list>
例如:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
另:hosts文件在windows中位置
原文:https://www.cnblogs.com/60kmph/p/14033909.html