In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Introduction to Tomcat
Tomcat server is a free and open source Web application server, which is a lightweight application server. It is widely used in small and medium-sized systems and not many concurrent access users. It is the first choice for developing and debugging JSP programs.
Tomcat and Nginx,APache (httpd), lighttpd and other Web servers, with the function of dealing with HTML pages, in addition, it is also a Servlet and JSP container, independent Servlet container is the default mode of Tomcat. However, Tomcat is not as capable of handling static HTML as Nginx/Apache servers.
Tomcat installation
1. Software preparation
JDK download: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Tomcat download: http://tomcat.apache.org/
2. Deploy JAVA environment JDK
(1) decompression and installation of jdk
[root@localhost ~] # tar xf jdk-8u60-linux-x64.tar.gz-C / usr/local/ [root@localhost ~] # ln-s / usr/local/jdk1.8.0_60 / usr/local/jdk
(2) configure java environment variables
[root@localhost ~] # sed-i.ori'$an export JAVA_HOME=/usr/local/jdk\ nexport PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH\ nexport CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar' / etc/profile [root@localhost ~] # tail-3 / etc/profileexport JAVA_HOME=/usr/local/jdkexport PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATHexport CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
(3) make the java environment variable take effect immediately
[root@localhost ~] # source / etc/profile
(4) check the installation of Java environment
[root@localhost ~] # which java/usr/local/jdk/bin/java [root@localhost ~] # java-version # the following message indicates that java version "1.8.0,60" Java (TM) SE Runtime Environment (build 1.8.0_60-b27) Java HotSpot (TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
Install tomcat
(1) decompress and install tomcat
[root@localhost ~] # tar xf apache-tomcat-8.0.27.tar.gz-C / usr/local/ [root@localhost ~] # ln-s / usr/local/apache-tomcat-8.0.27/ / usr/local/tomca
(2) configure tomcat environment variables
[root@localhost ~] # echo 'export TOMCAT_HOME=/usr/local/tomcat' > / etc/profile [root@localhost ~] # source / etc/profile
(3) check the configuration of environment variables.
[root@localhost] # tail-4 / etc/profileexport JAVA_HOME=/usr/local/jdkexport PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATHexport CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jarexport TOMCAT_HOME=/usr/local/tomcat
Start tomcat
* * Startup program: / usr/local/tomcat/bin/startup.sh
Close the program: / usr/local/tomcat/bin/shutdown.sh
Detailed explanation of Tomcat main configuration file Server.xml
Top-level components: located at the top level of the entire configuration, such as server.
Container class components: components that can contain other components, such as service,engine,host,context
Connector components: connect user requests to tomcat, such as connector.
Nested class components: in a container and cannot contain other components, such as Valve,logger.
Detailed explanation of components
Engine: the core container component, catalina engine, is responsible for receiving user requests through connector, processing the requests, and transferring the requests to the corresponding virtual host host.
Host: similar to virtual hosts in httpd, FQDN-based virtual hosts are generally supported.
Context: defines an application that is the innermost container class component (can no longer be nested). The main purpose of configuring context is to specify the root directory of the corresponding webapp, similar to httpd's alias, which can also specify additional properties for webapp, such as how to deploy, and so on.
Connector: receives user requests, similar to httpd's listen configuration listening port.
Service (service): associate the connector to the engine, so there can be multiple connector within a service, but only one engine engine. There are two connector inside the service, one engine. Therefore, in general, there is only one service inside a server, and there is only one engine inside a service, but there can be multiple connector inside a service.
Server: represents an instance of tomcat running in JVM.
Valve: valve that intercepts requests and performs some processing before transferring them to the corresponding webapp. It can be used in any container, such as logging (access log valve) and IP-based access control (remote address filer valve).
Logger: a logger that records state information within a component and can be used in any container except context.
Realm: can be used in components of any container class to associate a user authentication library for authentication and authorization. There are two types of authentication libraries that can be associated: UserDatabaseRealm,MemoryRealm and JDBCRealm.
UserDatabaseRealm: use the user authentication library customized by JNDI.
MemoryRealm: authentication information is defined in tomcat-users.xml.
JDBCRealm: the authentication information is defined in the database and connects to the database through JDBC to find the authenticated user.
Customize the default site directory
Method 1:
Just put meminfo.jsp or other programs in the tomcat/webapps/ROOT directory. Because the default site root is tomcat/webapps/ROOT
Method 2:
[root@tomcat ~] # vim / application/tomcat/conf/server.xml # add a line of code here in the virtual host to define the root path of the web site [root@tomcat ~] # / application/tomcat/bin/shutdown.sh [root@tomcat ~] # / application/tomcat/bin/startup.sh install Jpress using Tomcat
JPress, a java replacement version of wordpress, is developed using JFinal. Maven support is required
[root@localhost ~] # tar xf apache-maven-3.3.9-bin.tar.gz-C / usr/local/ [root@localhost ~] # ln-s / usr/local/apache-maven-3.3.9 / usr/local/maven [root@localhost ~] # tail-2 / etc/profileexport MAVEN_HOME=/usr/local/mavenexport PATH= "$MAVEN_HOME/bin:$PATH" [root@localhost ~] # source / etc/profile [root@localhost ~] # mvn-version # Indicates a successful Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5) 2015-11-10T11:41:47-05:00) Maven home: / usr/local/mavenJava version: 1.8.0: 60, vendor: Oracle CorporationJava home: / usr/local/jdk1.8.0_60/jreDefault locale: en_US, platform encoding: UTF-8OS name: "linux", version: "2.6.32-431.el6.x86_64", arch: "amd64", family: "unix"
* * put the jpress-web-newest.war package in the root directory of the Tomcat website
Put the war package in the root of the website
[root@localhost ~] # ls-l jpress-web-newest.war-rw-r--r--. 1 root root 20797013 Oct 24 17:04 jpress-web-newest.war [root@localhost ~] # mv jpress-web-newest.war / data/www/www/ROOT/# extract war package [root@localhost ~] # which jar/usr/local/jdk/bin/jar [root@localhost ~] # cd / data/www/www/ROOT/ [root@localhost ROOT] # jar xf jpress-web-newest.war # jar is the extract command of war package [root@localhost ROOT] # lsjpress-web-newest. War META-INF static WEB-INFmeminfo.jsp robots.txt templates
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.