Tomcat deploys multiple projects to access the cloud server

Here we talk about deploying multiple projects on the same tomcat and placing them on the server and accessing them through a browser.
If you are unfamiliar with tomcat architecture, you can browse my other article
https://blog.csdn.net/xiao_ma_csdn/article/details/79430363

Into the title

We know that Host represents a virtual host, and each virtual host matches a certain network domain
name . One or more Web Apps can be deployed (deploy) under each virtual host. Each Web App corresponds to a Context and has a Context path

So to deploy multiple projects, you only need to configure multiple service nodes, because a service can have multiple Connectors to configure multiple port ports, but there is only one Engine, and multiple Hosts can be configured in one Engine, but the Host of the same IP address There can only be one. Therefore, we need multiple service nodes to deploy multiple projects through the same ip address and different ports.

configure server.xml

<Server port="8005" shutdown="SHUTDOWN">

  <GlobalNamingResources>

    <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"
               connectionTimeout="20000"
               redirectPort="8443" />

    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

    <Engine name="Catalina" defaultHost="localhost">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

      </Host>
      <Host name="localhost2"  appBase="webapps/manyproject"
            unpackWARs="true" autoDeploy="true">     
      </Host>
    </Engine>
  </Service>

  <Service name="Catalina"><!-- 第二个service-->

    <Connector port="8090" protocol="HTTP/1.1"   <!-- 修改端口8090-->
               connectionTimeout="20000"
               redirectPort="8443" />

    <Engine name="Catalina" defaultHost="localhost">

      <Realm className="org.apache.catalina.realm.LockOutRealm">

        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
        <!--创建一个目录存放项目-->
      <Host name="localhost"  appBase="webapps/manyproject"  
            unpackWARs="true" autoDeploy="true">     
      </Host>
    </Engine>
  </Service>
</Server>

The projects in webapps/manyproject need to be pasted by themselves, and eclipse will only create them in webapps.
write picture description here
Access in local browser
write picture description here
write picture description here

After confirming that the project can be uploaded to the cloud server, you can use the FileZilla visual upload tool.

Set up security groups in the cloud server management console

write picture description here
Port 80 is the default port of http. If it is set to 80, it can be accessed directly through ip + project name.

Then you can access it through a browser.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324631953&siteId=291194637