In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Here are three ways to deploy a web project in Tomcat:
1. Deploy the unpackaged webapp directory
two。 Packaged war file
3.Manager Web application
One: deploy the unpacked webapp directory
One way to deploy a Web project into Tomcat is to deploy a Web project that is not encapsulated in a WAR file. To deploy an unpackaged webapp directory using this method, simply put our project (compiled release project, non-development project) in Tomcat's webapps directory. As shown in the following figure:
At this point, open the Tomcat server (make sure the server is open), and you can access our project in the browser, as shown in the following figure:
But at this time, we found that when visiting our project content, we had to add our project name "myweb", which was very bad. If we want to access it directly in the form of http://localhost:8080/index.html without adding a project name, it is as follows:
We found a 404 error. If we want to have normal access to our project through the above connection, we can edit the conf/server.xml to configure it.
Open the server.xml file and find the Host element. The default configuration is as follows:
We need to add the content of Context inside Host. After the addition, it is as follows:
At this point, you can access it through this http://localhost:8080/index.html without adding the project name. As follows:
(in fact, it can be accessed through the address of http://localhost:8080/myweb/index.html at this time. )
Two: packaged war files
In this way, simply put the packaged war file in the webapps directory. As shown in the following figure:
When we start Tomcat, the first thing Tomcat does is unpack the contents of the war file into a path with the same file name, take out the .war extension, and then read the project file from the unpacked directory. Now, let's start Tomcat, as shown in the following figure:
As you can see, there is an unpacked myweb folder in the webapps directory. It can then be accessed through the http://localhost:8080/myweb/index.html address in the browser. If we want to access it at the http://localhost:8080/index.html address, we also need to configure the server.xml file. The procedure is the same as above and will not be repeated.
Third: Manager Web mode
The Manager Web source application allows us to manage our own Web projects through Web. Of course, if anyone can manage other people's projects, things get a little tricky, not to mention security. So, when we want to manage our own projects through Manager Web, we need to set permissions.
First visit the Apache Tomcat welcome page.
At this time, we click on the circle in the figure, and we will be prompted to enter the user name and password. So we need to add roles to the conf/tomcat- users.xml file. Tomcat- users.xml does not add any roles by default. Because we are going to manage our project through Manager Web, we add the manager-gui role to it. As follows (the part in the circle is the role we added. Enter username freely, password freely, and roles fill the manager-gui above):
Configure 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 the relevant information about Tomcat, including Tomcat version, JVM version, JVM provider and so on, as shown below:
Go to the Manager App page to manage our project. The page is shown in the following figure:
Applications shows the project directory under the webapps directory: ROOT directory, doc directory, manager directory, all of which are included with Tomcat. We don't have our own project at this time. Now we begin to deploy our own project. Under Deploy, we see two ways: 1.Deploy directory or WAR file located on server;2.WAR file to deploy.
First of all, demonstrate the way to use 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 anywhere, and if you put it under webapps, Tomcat will be unzipped directly when you start Tomcat. If you put it in another location, when you start Tomcat, Tomcat will copy the myweb.war file to the webapps directory and extract it. Select the file and click Deploy to publish it. At this point, you can access it through http://localhost:8080/myweb/index.html in the browser.
At this point, let's take a look at the changes in the Manager App page, such as the circle in the following figure, with more of the myweb project we just released.
Next is the way of Deploy directory or WAR file located on server. Copy myweb.war to the webapps directory, fill in\ myweb after WAR or Directory URL:, and click Deploy to publish.
The above article on how to deploy a Web project in Tomcat (must see the article) is all the content shared by the editor. I hope I can give you a reference and support it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.