Three methods of Tomcat installation, use and deployment of Web projects

1. Download and decompress the Tomcat compressed package

1. Download the Tomcat compressed package

Official website download address: Tomcat official website

Click the link and follow the icon to download the corresponding compressed package. It is recommended to download to the root directory of the D drive

2. Tomcat decompression

Note that the decompression path must not contain Chinese, which is why it is recommended to download to the root directory of the secondary disk. The interface after decompression is shown in the figure.

2. Explanation and purpose of each file in the installation package

1.bin directory
stores important commands in Tomcat, the most important are two
1).startup.bat startup command
2).shutdown.bat shutdown command
2.conf directory
is used to store important configuration files, among which server.xml It contains the port number
Open the server.xml file and change the port number 8080 in line 69 to other numbers to avoid being occupied, mine is 8989
3.lib directory
stores various jar packages
4.logs directory
stores log files
5.temp directory
stores Temporary file
6.webapps
store Web projects

3. Deploy the Web project

1. Environment preparation

Tomcat is written in java language, so make sure that the environment variable JAVA_HOME is not misconfigured

The port number 8080 is easy to be occupied, modify it to 8989, the modification method is in 2 of the second title

2. Three deployment methods

2.1. Copy the entire project folder to webapps

Access path: http://ip:端口号/项目名/要访问的资源
ip generally writes localhost, which means the local ip address, or you can write your own computer ip address, for example:
1). http://localhost:8989/WebProgram/login.html
2.) http://192.168.1.8: 8989/WebProgram/login.html
can be double-clicked to use the startup.bat in the bin directory and then search the above URL. If you can access it, it means that the deployment is successful

2.2. Configure the project path in server.xml

Add inside the Host tag:
< Context path="The name of the project when it is accessed" docBase="The absolute path of the project" />

Note:
Usually the value in the path is the same as the project name, but the configured path value shall prevail, for example:
< Context path="wb" docBase="The absolute path of the project" />
Access method: http://localhost: 8989/wb/login.html

2.3. Create a new xml file deployment project

Create a new project name in conf\Catalina\localhost\.xml
Add a Context tag inside the xml and configure the docBase attribute

3. Instructions for use and supplementary knowledge points

1. Regardless of the deployment method, you need to double-click the startup.bat to start the server before you can access it. To close the server, it is recommended not to close the black window directly, but use the shutdown.bat command to close it

2. The difference between url and uri
url: the absolute path to access the project, for example: http://ip
uri: the relative path to access the project, must start with /

Guess you like

Origin blog.csdn.net/jcc4261/article/details/129632058