tomcat域名和项目路径绑定

 前提准备:

 linux云服务器, tomcat ,域名(已解析),项目war包

1、修改端口为80端口

因为80端口是为HTTP(HyperText Transport Protocol)即超文本传输协议开放的,浏览网页服务默认的端口号都是80,因此只需输入网址(或IP地址)即可。

打开tomcat安装目录,根据路径找到 server.xml   路径......\apache-tomcat-7.0.70\conf\server.xml  如下:将其中port="8080"修改为port="80"即可。

<Connector port="80" useBodyEncodingForURI="true" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443"  />

2、修改域名

找到如下字段:将localhost修改为自己自定域名

<Host name="www.5156ol.com"  appBase="webapps"
      unpackWARs="true" autoDeploy="true">

3、去掉项目名称

在第二部内容中继续添加如下内容,意思就是将webapps下的shsxtnote项目 /shsxtnote路径改为/ 访问,去掉项目名称。

<Context path="" docBase="/shsxtnote"  debug="0" reloadable="true"></Context>

是修改后的效果:

1

2

3

4

<Host name="www.5156ol.com" debug="0"  appBase="webapps"

      unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">

  <Context path="" docBase="/shsxtnote"  debug="0" reloadable="true"></Context>

 docBase这个量,它指定的是登录tomcat默认的主页所在的文件夹,这个量默认情况下指定的是ROOT文件夹。

4.修改tomcat访问默认首页

  conf/web.xml中。默认配置如下 

  1. <span style="font-family:SimSun;"><span style="font-size:14px;">    <welcome-file-list>  
  2.         <welcome-file>index.html</welcome-file>  
  3.         <welcome-file>index.htm</welcome-file>  
  4.         <welcome-file>index.jsp</welcome-file>  
  5.     </welcome-file-list></span></span>  

   如在此项目(shsxtnote)中默认的的首页也名为index.xxx话,可不作设置

猜你喜欢

转载自blog.csdn.net/ted_cs/article/details/80244086
今日推荐