LINUX服务器tomcat绑定域名

本文介绍LINUX服务器使用tomcat绑定单域名,且直接输入域名即访问到制定项目,例如输入www.xxx.com访问到名字为test的项目

共分三步,

第一步,配置ip

vi /etc/hosts

加入一行127.0.0.1 www.xxx.com


第二步,配置tomcat的server.xml文件

vi ${catalina_home}/conf/server.xml      (就是你tomcat安装目录下的conf文件下的server.xml文件)

这里粘出需要修改的部分,红色字体为修改的内容


<Engine name="Catalina" defaultHost="www.xxx.com">


      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->


      <!-- Use the LockOutRealm to prevent attempts to guess user passwords
           via a brute-force attack -->
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <!-- This Realm uses the UserDatabase configured in the global JNDI
             resources under the key "UserDatabase".  Any edits
             that are performed against this UserDatabase are immediately
             available for use by the Realm.  -->
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
      <Host name="www.xxx.com" appBase="webapps"
            unpackWARs="true" autoDeploy="true">
        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />-->
<!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" resolveHosts="false"/>
        <Context path="" docBase="$CATALINA_HOME/webapps/test"  reloadable="true" crossContext="true"/>
      </Host>
    </Engine>


第三步,删除ROOT目录


因为不删除ROOT目录不会访问到我们配置的项目

很多人没有配置成功就是因为没有删除该目录

cd $CATALINA_HOME/webapps

rm -R -f ROOT

启动tomcat试试吧




  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值