1.3 Ways to deploy Tomcat
with the web, you can deploy independently, provide your own containers, and provide your own web.
Proxy with Nginx or Apache, within a host, static content is done by the agent and forwarded to Tomcat for dynamic requests.
Two-tier deployment, one host running Apache, working in reverse proxy mode (Apache's proxy module has mod_proxy and MOD_JK), one host running Tomcat. Apache can respond to any tomcat host that forwards to the backend based on traffic or various other criteria of the client host, can monitor the health of the backend, and can disable or enable features on the remote host via a Web interface output Management page.
Tomcat itself is developed in the Java language, so deploying Tomcat requires you to install the JDK instead of the JRE.
The difference between JDK and JRE: Jre:java running environment. Jdk:javadevelopment development environment (JDK equivalent to a superset of JRE, providing development (compilation) and running environment)
2. Installation of JDK
Software is usually installed in three types: RPM package, Universal binary format (. bin end), source code compilation and installation.
This is installed in a common binary format, with OS REDHAT5.8,JDK version Jdk-6u21-linux-i586-rpm.bin
Installation Steps : "
After download
chmod +x Jdk-6u21-linux-i586-rpm.bin
./jdk-6u21-linux-i686-rpm.bin
Steps such as:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7F/DF/wKiom1cwT2bTXHAjAAA5EWF22Vc914.jpg "title=" JDK installation. jpg "alt=" wkiom1cwt2btxhajaaa5ewf22vc914.jpg "/>
The default installation is under/usr/java/, and the jdk1.6.0_21 is created in this directory
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7F/DF/wKiom1cwUaPS7Y9zAAAsetJ7_ZE141.png "title=" JDK directory. png "alt=" Wkiom1cwuaps7y9zaaasetj7_ze141.png "/>
jdk1.6.0_21 under each directory:
Bin: Store binaries, Java boot virtual machine, Javac complete compilation
Include: Header file,
LIB: library file
Man: Help documentation
to make it easy to use commands in the bin directory
Vim/etc/profile.d/java.sh Adding content to this file
Export java_home=/usr/java/jdk1.6.0_21
Export path= $PATH: $JAVA _home/bin
Save to read this file after exiting. /etc/profile.d/java.sh
You can use the statement java-version to view version information to test whether the JDK is configured properly
】
Java Configuration supported parameter methods for starting a virtual machine "
-xx:+<option>: Turns on the function specified by this parameter
-xx:-<option>: Off function
-XX:<OPTION>=<VALUE>: Assign a value to option specified
If java-xx:+printflagsfinal shows all the parameters supported by Java and their default values
-d<name>=<value> Setting system Property values
】
3. Tomcat Installation
This is done using apache-tomcat-7.0.23.tar.gz Installation
Unzip after download
Tar XF apache-tomcat-7.0.23.tar.gz-c/usr/local
cd/usr/local/
LN-SV apache-tomcat-7.0.23 Tomcat
Installation steps such as:
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7F/E0/wKiom1cwWTKgiextAAHiHUltGe0391.png "title=" Tomcat installation. png "alt=" Wkiom1cwwtkgiextaahihultge0391.png "/>
How do I start tomcat? "
Tomcat's code name is called Catalina.
1, the first output environment variable description Catalina where.
vim/etc/profile.d/tomcat.sh Adding content
Export Catalina_home=/usr/local/tomcat
Export path= $PATH: $CATALINA _home/bin
Executes the command after the add is complete. /etc/profile.d/tomcat.sh
catalina.sh version where version is a program in the bin directory under the Tomcat directory and can be passed as a parameter to catalina.sh for execution
Start Tomcat execution Command catalina.sh start
Use the JPS command to see if it is started, and use the netstat command to see if 8080 ports and 8009 ports are enabled
】
Tomcat can be accessed via http://IP:8080 after booting . This 8080 port is defined when the HTTP connector is defined in the Server.xml file in the Conf directory, using the command: Vim/usr/local/tomcat/conf/server.xml can be viewed, such as:
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7F/DD/wKioL1cwZWHBRDhsAAAeQBGPf1w055.png "title=" Connector.png "alt=" Wkiol1cwzwhbrdhsaaaeqbgpf1w055.png "/>
You can change this port to suit your needs. Use command after change:
catalina.sh Stop && catalina.sh start to restart, catalina.sh does not support restart.
Tomcat's directory structure : Cd/usr/local/tomcat into the tomcat directory
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7F/DD/wKioL1cwXJHhSyoFAABq0Ix5pCE210.png "title=" Tomcat directory. png "alt=" Wkiol1cwxjhhsyofaabq0ix5pce210.png "/>
the bin directory is a stack of Java Archive Compressed packages, window batch scripts, and shell scripts. The core script in the directory is catalina.sh.
The core profile in the conf directory is that the security of this file is important when Server.xml,tomcat is started and the tomcat-users.xml is read into memory to complete user account authentication. The default application deployment descriptor, Web. Xml. The default is the configuration file Context.xml provided by the context. Defines the security policy for Tomcat, such as which resources can be accessed and inaccessible, and which can be loaded which cannot be loaded configuration files are catalina.policy. Catalina.properties defines the application's own properties (the amount of memory used, the cache pool, and so on). Logging.properties defines log file properties (log level, log file path, and so on).
For us, we usually need to modify the configuration file only. xml files, other than to define the properties of the application itself, otherwise do not change.
Deploying an application is the process of placing it in a path that is accessible to a certain context of one of the hosts of a tomcat, and the ability to load the public and private classes on which it depends is called deployment. In a nutshell, the classes that a Web application relies on are loaded into the JVM.
How to deploy, where to find which files should be deployed, etc. are done by the deployment Descriptor Web. XML command.
lib directory: library
Logs directory: log
Temp directory: temp file directory
WebApps directory: deployed application directory, in this directory under each application directory under the-inf end of the directory is not allowed through the Web service access, is the application private files, private information.
Work directory: working directory, in this directory each engine has its own separate directory, in this engine directory each host also has a separate directory, in this host directory each application also has its own separate directory ( Applications can view Deploye applications through the catalina.out in the logs directory. The work directory structure and the applications viewed through catalina.out such as:
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7F/DD/wKioL1cwY--TgaK6AAArfdS25QM674.png "style=" float: none; "title=" Tomcat-work directory structure. png "alt=" Wkiol1cwy--tgak6aaarfds25qm674.png "/>
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7F/E0/wKiom1cwYxOQfR9oAAB5Rp67ViM099.png "style=" float: none; "title=" Deploy the application. png "alt=" Wkiom1cwyxoqfr9oaab5rp67vim099.png "/>
This article is from the "Gan mu" blog, please be sure to keep this source http://ganmu.blog.51cto.com/9305511/1771524
Deployment of Tomcat