Deploy local projects to remote servers

**

I want to record the deployment of a local project to a remote server, and I can finally use the domain name or public IP to directly access the project on the remote server

**
1: First of all, I want to explain what I have encountered before. I got a host's public network ip, which can be pinged through the command line, but I can't access it using a browser, and finally concluded that I didn't buy a domain name, then I bought a domain name, and then resolved the domain name, and the public network IP The addresses are linked, and the public domain ip: 80 port of the domain name mapping. Therefore, the browser accessing the domain name is equivalent to accessing the resource under port 80 of the remote host. The remote port 80 is used by the iis server by default. If we want to use the tomcat server, then we have to change the port 80 used by the IIS server by default to 81. Then go to the tomcat configuration file server.xml and change tomcat The port 8080 of the server is changed to port 80. In this way, the tomcat server accessed by the domain name is successful. Open the browser, enter the domain name, and display the "cat cat" page [tomcat default page]. If you find that port 80 is occupied during tomcat startup, go to cmd to open the command line, check which program occupies port 80, and then remove the occupation.

2: Put the local project into a war package and copy it to the tomcat webapps of the remote host. In order to allow the domain name to access the project, modify the configuration file server.xml
as follows: Change
Insert picture description here
the two localhost in the screenshot to your Domain name, www.xxxx.com or xxxx.com [both the first-level domain name and the second-level domain name are the same, depending on whether you can set it when you buy it], see the context tag is not, the operation is like the previous blog, like that After setting, you can remove the project name when you visit. After this, the access path can be www.xxx.com/test/index. Note that port 8080 is not added here, because we have changed the port to port 80, because the domain name visits port 80, so in the project You also need to set up the project to use port 80 accordingly. The screenshot does not release the context label, you can release this label yourself.

3: Then record how to set up in the project, you can directly access the project's login page or the home page you want to display at http: // localhost: 8080.


/*配置文件:初始化访问项目的登录页面*/

@Configuration
public class DefaultController  implements WebMvcConfigurer {
    @Override
    public void addViewControllers( ViewControllerRegistry registry ) {
        registry.addViewController( "/" ).setViewName( "forward:jsp/login2.jsp" );
        registry.setOrder( Ordered.HIGHEST_PRECEDENCE );
        WebMvcConfigurer.super.addViewControllers( registry );
    }
}

Declare a new class directly in the project, as shown in the code, directly modify that jsp / login2.jsp to the page you want to initialize access to. Note here, because the springboot framework is used, all aspects of configuration can be based on your own situation. By default: access to the resource folder accessed by static resources, but you can set it yourself and put the path of the access page directly. In this way, you can set the page that the project initializes to visit. Similarly, by redeploying the set project to a remote tomcat, we can use the domain name to directly access the project homepage. Note: Change the port number yourself ~~ There are solutions to all problems. If you do n’t understand, ask your classmates, ask your teacher, and search for [Baidu, Google] ~~~~~~~~~~~~~~~~~~

Published 13 original articles · Like1 · Visit 2006

Guess you like

Origin blog.csdn.net/qq_31152023/article/details/100652289