Multiple domain names, one host, multiple projects, different domain names correspond to different projects

Multiple domain names, one host, multiple projects, and different domain names correspond to different projects. I believe this problem will be tricky for everyone. The first thought was to use multiple tomcat servers, but you only have one port 80! ! !

Don't worry, analyze it first. Thinking of this, I think someone will think of using code to judge and then jump. Yes, you can make a separate project and put it on port 80 and then judge and jump, but it is too troublesome to do so! ! !

Here I tell you a simple method:

Detailed explanation of tomcat's Server.xml and configuration of Host

   You can open server.xml, turn to the bottom, and see the following configuration    

<Hostname="domain"appBase="webapps"unpackWARs="true"autoDeploy="true">

。。。。。

</Host>

name: domain name

appBase: You can create a new folder under toncat, such as webapps2, and copy the intermediate configuration file into it, which is equivalent to having two wenapp folders, and you can also put multiple projects in wenapp, and you can also use ROOT folder, is this perfect?


Here is the detailed explanation:

  • name: Set the domain name of the virtual host, or directly fill in the ip address of the server, such as 192.168.1.10.
  • autoDeploy : Whether to allow automatic deployment, the default value is true, which means that Tomcat will automatically detect the file changes under the appBase directory and automatically apply them to the running Web application.
  • unpackWARs: Set whether to automatically expand the war archive before running the web application, the default value is true.
  • appBase : Sets the path to the web application group. As mentioned earlier, a virtual host can be composed of multiple web applications, so the directory pointed to by appBase here should be the directory that is prepared to store this group of web applications, not the directory itself of a specific web application ( even if the virtual host consists of only one web application). The value of the appBase attribute can be a relative path relative to the Tomcat installation directory, or an absolute path. It should be noted that this path must be accessible to Tomcat. Tomcat installed from Arch Linux sources is run by the tomcat user, so After creating a new appBase directory, you can use the chown command to change the owner of the directory.

Guess you like

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