tomcat配置通过域名直接访问项目首页的完整步骤

java
专栏收录该内容
15 篇文章0 订阅
订阅专栏
欢迎访问个人在线工具类网站:https://www.ctools.top
我们以tomcat为例通过输入域名直接访问项目首页的配置方法。我的域名为:www.ctools.top,也欢迎大家访问。
第一步:申请一个域名并做好DNS域名解析,或者本地修改host域名指向。域名指向的修改方法为:

在hosts文件最后一行添加:127.0.0.1 www.ctools.top

第二步,将index.html设置项目的默认首页,修改项目的web.xml文件
 

    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
第三步:将tomcat访问端口号更改为 80,更改后可以通过访问www.ctools.top 查看是否访问到猫的界面。

  <Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"  redirectPort="8443" />
第四步:将Engine标签下的defaultHost更改为你设置的域名。

<Engine name="Catalina" defaultHost="www.ctools.top">
第五步:更改<Host></Host>标签下的name值为访问的域名。
 

<Host name="www.ctools.top"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
第六步:在</Host>标签前添加<Context docBase="ctools" path="" reloadable="true" />。其中docBase为需要访问的项目名称。

<Context docBase="ctools" path="" reloadable="true" />
到此配置完成。可以重新启动tomcat输入域名测试。直接在浏览器中访问你的域名即可。

完整的tomcat配置文件server.xml内容如下:
 

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at<

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值