【记录】在云服务器安装tomcat部署自己的项目 通过ip无需加端口号直接访问

直接记录自己的server.xml代码:
以下代码配置后可以通过ip+8080访问:


<Server port="-1" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />

  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>


  <Service name="Catalina">

 
    <Connector port="8080" protocol="HTTP/1.1"
	address="0.0.0.0" 
               connectionTimeout="20000"
               redirectPort="8443"
  URIEncoding="UTF-8"
  />
      <Connector port="8080" protocol="AJP/1.3"
             address="0.0.0.0" 
               redirectPort="8443" 
			   URIEncoding="UTF-8"
			   />

      <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="121.5.227.176"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
<Context path="" docBase="C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\ROOT" reloadable="true" />

        <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" />

      </Host>
    </Engine>
  </Service>
</Server>

在这里插入图片描述
设置直接通过ip访问(不需要端口号)
在这里插入图片描述
我先是在网站绑定当中删除80端口
然后

在这里插入图片描述

 <Connector port="80" protocol="HTTP/1.1"
	address="0.0.0.0" 
               connectionTimeout="20000"
               redirectPort="8443"
  URIEncoding="UTF-8"
  />
      <Connector port="80" protocol="AJP/1.3"
             address="0.0.0.0" 
               redirectPort="8443" 
			   URIEncoding="UTF-8"
			   />
<Engine name="Catalina" defaultHost="121.5.227.176">

      <!--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="121.5.227.176"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
<Context path="" docBase="C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.0\webapps\ROOT" reloadable="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" />

      </Host>
    </Engine>

另外看了很多帖子好像都是在eclipse里面打开tomcat,我没有用eclipse打开,直接是安装了tomcat9,然后把static和index.html粘贴到webapps下面,然后那个</context 的配置我也不知道是咋回事,好像很多帖子是有项目名,但是我的貌似没有项目名

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值