Original: http://my.oschina.net/sunchp/blog/90235
One: Related concepts
Catalina_home:tomcat installation directory
Catalina_base:tomcat working Directory
Context: A Web application
Two: Deployment Method (Petweb project as an example, the Petweb directory is assumed to be c:/petweb)
① $CATALINA _base/webapps (General method)
Copy the Petweb directory to $catalina_base/webapps and start the server, and the app will be loaded automatically when Tomcat starts.
The access address is as follows: http://localhost:8080/PetWeb/
WebApps is the directory where Tomcat hosts the web App by default , there is a "root" (all uppercase) directory under WebApps , accessed by default http://localhost:8080/is the app that accesses the root directory .
Configuration and modification of WebApps and root in configuration in Server.xml in the Conf directory.
② modifying Server.xml file Deployment (not recommended)
This way you can not copy the Petweb directory to WebApps. To change the $catalina_base/conf/server.xml file, create a context within the host tag as follows:
1 |
< Context path ="/Pet" reloadable ="false" docBase ="C:/PetWeb" workDir ="d:/Mywebapps/emp" /> |
Path: Represents the route of the access, as in the above example, access to the application address is as follows: http://localhost:8080/Pet/
Reloadable: Indicates that the class package can be loaded automatically at run time under the classes and Lib folders. where reloadable= "false" means that the server does not automatically load after the content in the application is changed, and this property is usually set to true during the development phase, which is easy to develop, and should be set to false in the release phase to increase the access speed of the application.
Docbase: Represents the path to the application, note the direction of the slash "/". Docbase can use absolute paths, or relative paths, relative to WebApps.
Workdir: Represents the drop address of the cache file.
③ Creating a context XML file (recommended)
File name arbitrary, preferably with your Web application is the same ease of management, note that this file name as the context of the path attribute value, regardless of the Path property value in the file is set is not valid, the contents are as follows:
<
Context
docBase ="C:/PetWeb"
debug ="0" privileged ="true" reloadable ="false" >
</
Context
>
Place the XML file in the following:
$CATALINA _base/conf/[enginename]/[hostname]/
Three: Delete Web Apps
Deleting a web app deletes the relevant file content from the three locations above:
Delete the corresponding folder under WebApps; the corresponding context in the Server.xml; $CATALINA _base/conf/[enginename]/[hostname]/the corresponding XML file.
-------------------------------------------------------------------------------------------
Ps:tomcat official note about the context (XML description file for Web App: context.xml)
In talking about deployment of Web applications, the concept of a Context are required to being understood. A Context is the what Tomcat calls a Web application.
In order to configure a context within Tomcat a context descriptor is required. A context descriptor is simply the XML file that contains Tomcat related configuration for a context, e.g naming resources or Session Manager configuration. In earlier versions of Tomcat the content of a Context descriptor configuration is often stored within Tomcat ' s primary c onfiguration file Server.xml It is now discouraged (although it currently still works).
Context descriptors not-only-help Tomcat to know-configure contexts but other tools such as the Tomcat Manager and TCD often use these Context descriptors to perform their roles properly.
The locations for Context descriptors is:
$CATALINA _base/conf/[enginename]/[hostname]/context.xml
$CATALINA _base/webapps/[webappname]/meta-inf/context.xml
Files in (1) is named [Webappname].xml but files in (2) is named Context.xml. If A context descriptor is not provided for a context, Tomcat configures the context using default values.
Three ways Tomcat deploys web apps