Install Tomcat 8 under Linux 6

Source: Internet
Author: User
Tags tomcat server apache tomcat

Tomcat server is a free open source Web application server, belongs to the lightweight application server, in small and medium-sized systems and concurrent access users are not widely used, is the first choice to develop and debug JSP programs. Like a Web server like IIS, Tomcat has the ability to handle HTML pages, and it is also a servlet and JSP container, and the standalone servlet container is the default mode for Tomcat. With the proper configuration, Apache is the HTML page service, Tomcat runs JSP pages and Servlets, thus separating the Web server from the application service. This article mainly describes the installation of Tomcat 8 under Linux 6.

1, this article environment introduction:
os版本:centos6.564bitjdk版本:1.7.0_80tomcat版本:8.0.29apache版本:2.4.9apache服务器IP:192.168.21.10/24所有安装文件可到apache以及oracle官网下载
2. Install Java JDK
# CD/USR/LOCAL/SRC# chmod u+x jdk-7u80-linux-x64.rpm# RPM-UVH jdk-7u80-linux-x64.rpm# java-versionJava version"1.7.0_80"Java (TM)SERuntime Environment (build1.7. 0_80-B15) Java HotSpot (TM) --bit ServerVMS(Build24.80-B11, Mixed mode)# vi/etc/profile.d/java.shExport Java_home=/usr/java/latest export path= $PATH: $JAVA _home/bin# source/etc/profile.d/java.sh# Env|grep JAVAJava_home=/usr/java/latest# ls-hltr/usr/java/Total4.0K Drwxr-xr-x.8Root root4.0K-Nov -  -: AboutJdk1. 7. 0_80 lrwxrwxrwx.1Root root +Nov -  -: AboutLatest-/USR/JAVA/JDK1. 7. 0_80 lrwxrwxrwx.1Root root -Nov -  -: About default/usr/java/latest
3. Installing and Testing Tomcat
# TAR-XVF Apache-tomcat-8.0.29.tar.gz-c/usr/local# Ln-sv/usr/local/apache-tomcat-8.0.29/usr/local/tomcat'/usr/Local/tomcat' /usr/local/apache-tomcat-8.0.29 '# vi/etc/profile.d/tomcat.shExport catalina_home=/usr/Local/tomcat export path= $PATH: $CATALINA _home/bin# source/etc/profile.d/tomcat.sh# $CATALINA _home/bin/startup.sh # # #也可以使用catalina. sh script StartUsing catalina_base:/usr/Local/tomcat--auhtor:leshamiUsing Catalina_home:/usr/Local/tomcat--blog:http://blog.csdn.net/leshamiUsing Catalina_tmpdir:/usr/Local/tomcat/temp using Jre_home:/usr/java/latest using CLASSPATH:/usr/Local/tomcat/bin/bootstrap.jar:/usr/Local/tomcat/bin/tomcat-juli.jar Tomcat started.# netstat-nltp|grep # # # #tomcat缺省端口为8080, AJP for 8089,shutdown port for 8005Tcp0      0:::8080:::* LISTEN2150/java TCP0      0:: FFFF:127.0. 0. 1:8005:::* LISTEN2150/java TCP0      0:::8009:::* LISTEN2150/java# catalina.sh VersionUsing catalina_base:/usr/Local/tomcat Using catalina_home:/usr/Local/tomcat Using Catalina_tmpdir:/usr/Local/tomcat/temp using jre_home:/usr using CLASSPATH:/usr/Local/tomcat/bin/bootstrap.jar:/usr/Local/tomcat/bin/tomcat-juli.jar Serverversion: Apache tomcat/8.0.Server Built:nov -  -  the: -:xxUTC Server Number:8.0.. 0OS name:linux os Version:2.6.-431.el6.x86_64 architecture:amd64 JVM Version:1.7. 0_80-b15 JVM vendor:oracle Corporation# Curl Http://localhost:8080/<! DOCTYPE html> "en"> "UTF-8"/> <title>apache tomcat/8.0.</title> <link href="Favicon.ico" rel="icon"Type="Image/x-icon"/> <link href="Favicon.ico" rel="shortcut icon"Type="Image/x-icon"/> <link href="Tomcat.css" rel="stylesheet"Type="Text/css"/> # catalina.sh Stop
4. Configuring Tomcat for system service
# Vi/etc/init.d/tomcat #!/bin/sh # tomcat init script for Linux.    # # chkconfig:2345 # description:the Apache Tomcat servlet/jsp container. Java_home=/usr/java/latest catalina_home=/usr/local/tomcat export java_home catalina_home exec $CATALINA _home/bin /catalina.sh $*# Service TomcatStart    UsingCatalina_base:/usr/Local/tomcatUsingCatalina_home:/usr/Local/tomcatUsingCatalina_tmpdir:/usr/Local/tomcat/tempUsingJre_home:/usr/java/latestUsingCLASSPATH:/usr/Local/tomcat/bin/bootstrap.jar:/usr/Local/tomcat/bin/tomcat-juli.jar Tomcat started.# Service Tomcat stopUsingCatalina_base:/usr/Local/tomcatUsingCatalina_home:/usr/Local/tomcatUsingCatalina_tmpdir:/usr/Local/tomcat/tempUsingJre_home:/usr/java/latestUsingCLASSPATH:/usr/Local/tomcat/bin/bootstrap.jar:/usr/Local/tomcat/bin/tomcat-juli.jar# Chkconfig--Addtomcat# Chkconfig Tomcat on
5. Tomcat-related configuration files
server.xml:    核心配置文件context.xml:    每个webapp都有其配置文件,这些配置文件通常位于webapp应用程序目录下的WEB-INF目录中,    用于定义会话管理器、JDBC;此配置文件用于为所有的webapp提供默认配置;web.xml:    每个webapp部署之后才能被访问; 此文件则用于为所有webapp提供默认部署方式的配置;tomcat-users.xml:    用户认证账号配置文件;catalina.policy:    当使用-security启动tomcat实例时会读取此配置文件来其安全运行策略;catalina.properties:    Java属性的定义文件,用于设定类加载器路径,以及一些JVM性能调整的相关参数;logging.properties:    日志相关的配置信息;
6. Tomcat Frame composition
The Tomcat component is implemented by the Java class, some components are implemented in more than one way, some are nested, and each component needs to pass some properties when implemented by the specified type; top class components: Server (representing a Tomcat instance), at the top level of the configuration hierarchy, and have a strict correspondence with each other; service Class components: services (associating connectors to internal engine) container class components: engine (for a web container), Host,context Connector component: Connector HT TP, HTTPS, AJP (Apache Jserv procotol) connection client (can be browser or Web server) request to servlet container is nested class component: Valve, logger, realm,...is located in a container, but cannot contain other components; The Master profile is organized in the following structure: <Server> <Service> <connector/>...<Engine> <Host> <Context> </Context>...</Host>...</Engine> </Service>...</server> Context Definition Example: "Www.ycdata.net"Appbase="/WebSite"unpackwars="true"autodeploy="true"> <context path=""Docbase="WebApps"reloadable="true"/> </Host>
7. Description of the common components:
Server: one instance of Tomcat, which is a top-level component, typically a JVM can contain only one Tomcat instance, and one physical server can start a Tomcat instance in each JVM in the case of multiple JVMs. Each instance is part of a separate management port. Service: A service component typically contains one engine and one or more connectors associated with the engine; naming a service makes it easy for administrators to identify the logs generated by different services in the log file; One server can contain multiple service components, but typically only one ser Vice assigns a server. Connector (connectors): The connector class component, which is responsible for connecting the client (which can be a browser or Web server) to a Web application within the servlet container, usually referring to the location where the client sent the request and the server-side allocation port; The default port is usually the HTTP protocol8080, administrators can also change this port according to their needs; an engine can configure multiple connectors, but these connectors must use different ports. The default connector is based on the http/1.1The Coyote. At the same time, Tomcat supports AJP, Jserv, and JK2 connectors. Engine: A container class component, which refers to the servlet engine component that processes the request, the Catalina Servlet engine, which examines the HTTP header information for each request to identify which host the request should be sent to orContextand returns the requested processing result to the appropriate client.    In a strict sense, a container does not have to be implemented by an engine, it can be just a container.    If Tomcat is configured as a standalone server, the default engine is an already defined engine.    If Tomcat is configured as the back end of the Apache Web server that provides the servlet functionality, the default engine is ignored because the Web server itself can determine where to send the user request. An engine can contain multiple host components. Host: The host component is similar to a virtual host in Apache, but only the FQDN-based "virtual host" is supported in Tomcat. An engine must contain at least one host component. ContextContext):ContextA component is the most hierarchical component that represents the Web application itself. Configure aContextThe main thing is to specify the root directory of the Web application so that the servlet container can send user requests to the correct location.ContextA component can also contain a custom error page to provide a friendly hint when a user accesses an error. Nested class (nested) components: Such components are typically contained in container class components to provide services with management capabilities, they cannot contain other components, but some can be configured by different tiers of containers individually.    Valve: Used to intercept a request and perform some processing before it is transferred to the target, similar to the filter defined in the servlet specification. Valve can be defined in the components of any container class.    Valve is often used to record information such as client requests, client IP addresses, and servers, and this processing technique is often referred to as request dumps (requestdumping). The request dump Valve records the HTTP header information and cookie information file in the request client request packet, and the response dump Valve records the header and cookie information of the response packet into the file. Logger (Logger): Used to record state information inside a component, which can be used in addition toContextIn any container other than the Logging functionality can be inherited, so an engine-level logger will record information about all components within the engine, unless an internal component defines its own logger component.    Realm: For authentication and authorization of users; When you configure an application, the administrator can define roles and permissions for each resource or resource group, and these access control functions need to be implemented through Realm.    Realm authentication can be implemented based on text files, database tables, LDAP services, and so on.    Realm's utility extends across the entire engine or top-level container, so all applications within a container share user resources. At the same time, realm can be inherited by the subcomponents of its component, or it can be overridden by realms defined in the quilt component.
8. Tomcat directory Structure
* Bin-only theFollowingFiles: * SETENV.SH (*nix)orSetEnv.bat (Windows), * Tomcat-juli.jar The setenv scripts were described above. The Tomcat-juli library is documentedinch  theLogging Chapterinch  theUser Guide. * Conf-server ConfigurationFiles(including Server.xml) * lib-libraries andClasses asExplained below * Logs-log andOutputFiles* Webapps-automatically loaded Web applications * work-temporary workingDirectories  forWeb applications * Temp-directory used by  theJvm forTemporaryFiles(Java.io.tmpdir)

Install Tomcat 8 under Linux 6

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.