Common problems when deploying projects using tomcat on a computer

Common problems when deploying projects using tomcat on a computer

1. Normal project deployment
1. Deploy the unpacked webapp directory
One of the ways to deploy a web project to Tomcat is to deploy a web project that is not packaged in a WAR file. To deploy an unpackaged webapp directory using this method, just place our project (compiled release project, non-development project) in Tomcat's webapps directory.
2. Packaged war package project
In this case, you only need to place the packaged war package in the webapp directory corresponding to tomcat and start tomcat.
3, Manager Web mode
Manager Web source application allows us to manage our own Web projects through the Web. Of course, if anyone can manage other people's projects, things get a little trickier, not to mention security. Therefore, when we want to manage our own projects through Manager Web, we need to set permissions.
insert image description here
At this time, when we click on the circled part in the figure, we will be prompted to enter a user name and password. So we need to add roles in conf/tomcat-users.xml file. tomcat-users.xml does not add any role by default. Because we want to manage our project through Manager Web, we add manager-gui role inside. As follows (the part in the circle is the role we added, just fill in username, password, and roles fill in the manager-gui above):
insert image description here
After configuring this, restart the server, and you can enter the management interface.

Go to the Server Status page to view the status of the server and see Tomcat related information, including Tomcat version, JVM version, JVM provider, etc., as shown below:
insert image description here
Enter the Manager App page to manage our projects.
The project directory under the webapps directory is displayed under Applications: ROOT directory, doc directory, manager directory, which are all provided by Tomcat. At this time there is no project of our own. Now let's start deploying our project. Under Deploy, we see that there are two ways: 1.Deploy directory or WAR file located on server; 2.WAR file to deploy.

First demonstrate the way through WAR file to deploy.

myweb.war is our packaged project file, click "Select File" to select our project file on our host. This file can be placed in any location. If it is placed under webapps, then when Tomcat is started, Tomcat will be decompressed directly. If it is placed in another location, then when Tomcat is started, Tomcat will copy the myweb.war file to the webapps directory, and then decompress it. Select the file and click Deploy to publish. At this time, it can be accessed through the browser.
2. On the same computer, use multiple tomcats to start multiple projects.
In our normal development process, we usually encounter various scenarios. For example, the company has multiple systems, and now they need to be deployed on the same computer. However, when multiple tomcats are started at the same time, there will be a flashback. The following is to solve this problem. approach to class problems.
First, we find the locations of these tomcats, then enter the system environment variables, and configure the CATALINA_BASE and CATALIN_HOME variables for these tomcats, as shown in the figure: It
insert image description here
should be noted here that the variable names are suffixed with numbers such as 123, and the configured values Use the address of the tomcat.
As for why these two variables are created, the reason is that when the system does not configure these two variables separately, when tomcat starts, it will read the values ​​in these two variables by default to configure the tomcat path to start, and start multiple tomcats at the same time. When the paths are the same again, one of them will flash back, causing the startup to fail;
this can be found in the tomcat-2 >> bin >> catalina.bat file and the tomcat-2 >> bin >> startup.bat file, because tomcat Startup is mainly to read these two files;
next:
modify tomcat-2 >> bin >> catalina.
Modify all CATALINA_HOME in tomcat-2 >> bin >> catalina.bat file to CATALINA_HOME2;
modify all CATALINA_HOME in tomcat-2 >> bin >> startup.bat file to CATALINA_HOME2;

(replace with global search)

Finally, modify the port number in tomcat-2 >> conf >> server.xml; there are three modifications.
insert image description here
After completing the above operations, several tomcats can be started normally.

Guess you like

Origin blog.csdn.net/fzt12138/article/details/123346060