First, the basic deployment
There is a WebApps directory under the Tomcat installation directory, which holds all Web applications, and Tomcat automatically manages all web apps in that directory. As a result, the simplest way to deploy is to copy the Web app you want to deploy directly to the WebApps directory in the Tomcat installation directory.
This approach is typically used in the development process. There may be limitations in real project implementations: When using a leased (or someone else's) Web server, the drive letter of the server is not able to copy the Web application to the drive letter if there is permission control, you cannot deploy the project in this way, only in the following ways.
Second, modify the configuration file
The Conf directory under the Tomcat installation directory is used to store Tomcat's configuration files, and the Server.xml file in this directory is used to configure information about the server. The physical path and virtual path of the Web app are configured through the child element <context/> In the final
<context docbase= "C:\MyDemo" path= "/test"/> |
DocBase: Specifies the path where the web app resides;
Path: Specifies the path to access the app, that is, if you follow the above configuration, the path to the Web app should be: http://localhost:8080/test/resource name.
Note:the first letter of the context tag is uppercase C.
The element should be at the last position in the
Unpackwars= "true" autodeploy= "true" Xmlvalidation= "false" Xmlnamespaceaware= "false" > <context docbase= "C:\MyDemo" path= "/test"/> </Host> |
This is a convenient way to do this, without having to copy the Web app and not requiring the Web app's location to be under the same drive letter as the Tomcat server. However, TOMCAT6 is not recommended this way at first, because it destroys the file structure of Tomcat and modifies the Tomcat configuration file. Tomcat6 starts with the following approach.
III. Expansion of deployment
This approach is extended on the basis of the previous approach and avoids modifying the Tomcat configuration file. Go to the following path "Tomcat installation directory/conf/catalina/localhost", by default, The localhost directory only host-manager.xml and manager.xml two files, you can define an XML file to configure the project to be deployed, the file name is a virtual path, the above path is: Test.xml, if there is a multilayer path, the # interval, If the path is http://localhost:8080/a/b/c, the file name is A#b#c.xml. Configure the Web app's physical path directly from the <context/> element's Docbase property in the file:
<context docbase= "C:\MyDemo"/> |
You do not need to restart the server in this way, and you do not have to modify the Tomcat file, just extend it. This approach is recommended in the actual deployment.
Summary
1, the copy is applied to the WebApps directory;
2. Add <context/> Tag before </Host> in conf directory
<context docbase= "Physical path" path= "/virtual path"/> |
3. Add the "virtual path. xml" file under the Conf/catalina/localhost directory:
<context docbase= "Physical path"/> |
Three ways to deploy web apps [Go]