tomcat installation and deployment

Preparing the environment:

Installation tomcat8 jdk-1.8

tomcat start and stop

chmod +x /../apache-tomcat-8.5.42/bin/*

mkdir /../apache-tomcat-8.5.42/logs

/opt/apache-tomcat-8.5.42-src/bin/startup.sh

/opt/apache-tomcat-8.5.42-src/bin/shutdown.sh

Error: Can not find or load the main class org.apache.catalina.startup.Bootstraporg.apache.catalina.startup.Bootstrap

Solution: This is due to the bootstrap.jar tomcatan bin directory under the installation path can not be found, like adding jar package, you can replace download source bootstrap.jar into the bin directory

 

Four ways tomcat deployment project

1. In the configuration file of the host element server.xml

<Context path = "/ JavaWebApp" docBase = "/ opt / javaweb" /> # Note Context capitalized, otherwise it is not recognized

In this tag you can add to the / opt / javaweb this JavaWeb application mapped to JavaWebApp this virtual directory, the virtual directory is JavaWebApp Tomcat server management, JavaWebApp does not exist on a hard disk directory, just our own write a directory, which is a virtual directory, so called "virtual directory"

 

Context context indicates, is represented by a JavaWeb application, Context element has two attributes,
path: like to configure the virtual directory must start with "/."
docBase: Configure this virtual directory seems to correspond to the Web application resides on the hard disk directory.
Use your browser to access "/ JavaWebApp" The 1.jsp this web resources in the virtual directory
Note: in this way must be restarted to take effect

 

2. Let tomcat server to automatically map

tomcat server automatically manages all the web applications in the webapps directory and map it to like a virtual directory. In other words, tomcat webapps directory of the web server application, direct access to the outside world.

For example: the JavaWebs D drive this JavaWeb applied directly copy to tomcat webapps directory server, the Tomcat server at this time will automatically JavaWebs this JavaWeb application mapping a virtual directory of the same name "/ JavaWebs"

 

3. \ conf \ Catalina \ to add a file extension of xml, xml file name can be arbitrarily taken, under localhost directory in tomcat server such as JavaWebs.xml

Add Context Element Mapping JavaWeb JavaWebs.xml application file, as follows:

<Context path="/testweb" docBase="/opt/testweb" />

Note: xml file name (for example: JavaWebs.xml) as property values in the path Context, regardless of the file's path on how to set the property value is invalid, access paths above example is: http: // localhost: 8080 /

advantage

1) items can be stored in any location on the server, not necessarily under tomcat directory.

2) project deployment configuration file is not in the server.xml file, and the file tomcat decoupling.

3) configuration flexibility, small intrusion on the server.

4) timely entry into force without the need to restart the tomcat service

 

4.war package deployment

War deployment package and deploy Web directory is the same, is nothing but war package is compressed it, as long as the war package copied to the directory of tomcat can, without decompression. If you do not modify the server configuration file, then copied to the webapps directory.

Automatically extract the war package to generate a project directory after tomcat start.

 

Guess you like

Origin www.cnblogs.com/fanggege/p/11128186.html