Tomcat building and basic application under Linux

Source: Internet
Author: User
Tags tomcat server jcenter

1. About Tomcat:

Tomcat is a core project in the Jakarta Project of the Apache Software Foundation (Apache Software Foundation),Apache, Sun and a number of other companies and individuals developed together.The Tomcat server is a free open source Web application server, which is a lightweight applicationServer, which is widely used in small and medium-sized systems and concurrent access users, is the first choice for developing and debugging JSP programs. Tomcat and like a Web server like IIS, with the ability to handle HTML pages, it is also a servlet and JSP container, and the standalone servlet container is the default mode for Tomcat. However, Tomcat is less capable of handling static HTML than the Apache server.


2, the Tomcat-server components:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/C6/wKioL1XtNf7BzFbPAAEcqj-7_pY491.jpg "title=" 4.png " alt= "Wkiol1xtnf7bzfbpaaecqj-7_py491.jpg"/>

1), server: An element representing the entire Catalina container;


2), Service: It consists of one or more connector, and an engine, responsible for processing all connector received customer requests;


3), Connector: A Connector will listen for the customer request on a specified port and give the request to the engine to process, receive a response from the engine and return to the customer.

Tomcat has two typical connector:
Coyote http/1.1 Connector listens for Http requests from customer browser at port 8080;
Coyote JK2 Connector listens for servlet/jsp proxy requests from other webserver (Apache) at Port 8009;


4), Engine:engine can be configured to host virtual hosts, each virtual host has a domain name, when the Engine obtains a request, it matches the request to a host, and then the request to the host to process, The engine has a default virtual host, which is handled by the default host when the request cannot be matched to any host.


5), host: On behalf of a virtual host, that is, each virtual host and a network domain name to match, each virtual host can deploy (deploy) one or more Web apps, each Web app corresponds to a context , there is a context path, when the host obtains a request, it will match the request to a context, and then the request to the context to process, the matching method is "longest match", so a path== "" Context will become the default context for the host
All requests that cannot match the path names of other context will eventually match the default context;


6), Context: A context corresponds to a Web application, a Web application consists of one or more servlets, the context will be created according to the configuration file $catalina_home/ Conf/web.xml

$WEBAPP _home/web-inf/web.xml Loads the servlet class, when the context obtains the request, it looks for the matching servlet class in its own mapping table (mapping table), executes the class if found, and obtains the requested response. and returns.


3. Experimental environment:

Operating system: centos-6.5-i386

Software version: jdk-7u45-linux-i586.rpm------Java Compilation environment

apache-tomcat-7.0.42.tar.gz----Use Tomcat's green package here

Javacenter_home_gbk.zip------JSP-based Forum source code



4, the experimental process:

1), install the Java Operating environment JDK:

[[email protected] ~]# Yum localinstall jdk-7u45-linux-i586.rpm-y----can use this method to automatically resolve dependencies


2), after the installation is complete, query the installation directory and bin directory of the JDK and add the path to the system variables:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/C5/wKioL1XtL7-y5XnxAAG8T9EexjQ188.jpg "title=" 1.png " alt= "Wkiol1xtl7-y5xnxaag8t9eexjq188.jpg"/>

Edit/etc/profile, add path

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/C5/wKioL1XtMK-Q3iqQAADKUEaADwg537.jpg "title=" 2.png " alt= "Wkiol1xtmk-q3iqqaadkueaadwg537.jpg"/>


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/C8/wKiom1XtLpCxRFEuAAFIO3pVQTw620.jpg "title=" 3.png " alt= "Wkiom1xtlpcxrfeuaafio3pvqtw620.jpg"/>

After the configuration is complete, review the version of the Java environment

[[email protected] ~]# Java-versionjava version "1.7.0_45" Java (TM) SE Runtime Environment (build 1.7.0_45-b18) Java HOTSPO T (TM) Client VM (build 24.45-b08, mixed mode, sharing)

3), disassemble the Tomcat source package to/usr/local/src/:

[Email protected] ~]# TAR-ZXVF apache-tomcat-7.0.42.tar.gz-c/usr/local/src/


Under/usr/local/src/, move the Tomcat source bundle to/usr/local/and rename it to Tomcat:

[Email protected] src]# Pwd/usr/local/src[[email protected] src]# mv apache-tomcat-7.0.42//usr/local/tomcat


4), Tomcat's working directory

/usr/local/tomcat
|---bin Tomcat: Store startup and shutdown Tomcat scripts;

|---conf: Store different configuration files (server.xml and Web. xml);
|---lib: a library file (JARS) to store Tomcat operations;
|---Logs: storing the log file for Tomcat execution;
|---webapps:tomcat's main Web publishing directory (including application examples);
|---Work: Store the class file generated by the JSP after compiling;


5), enter the/usr/local/tomcat/bin directory, execute the startup script, and view the port:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/C6/wKioL1XtOeyR36OSAAJmVgwV2dc053.jpg "title=" 5.png " alt= "Wkiol1xtoeyr36osaajmvgwv2dc053.jpg"/>

[Email protected] bin]#/catalina.sh startusing catalina_base:/usr/local/tomcatusing catalina_home:/USR/LOCAL/TOMC Atusing catalina_tmpdir:/usr/local/tomcat/tempusing jre_home:/usrusing CLASSPATH:/usr/local/tomcat/bin/boo Tstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/CA/wKiom1XtODaAed8oAAMj20dGzKM681.jpg "title=" 6.png " alt= "Wkiom1xtodaaed8oaamj20dgzkm681.jpg"/>


Access Test (primary site IP address: 192.168.47.100)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/C6/wKioL1XtOsSA5KIzAARymTJ_qPo166.jpg "title=" 7.png " alt= "Wkiol1xtossa5kizaarymtj_qpo166.jpg"/>

The first execution is slower because Tomcat interprets the requested page as the Java language, and then requests the page later, and the speed is normal, by looking at the. class file that can be found after interpretation.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/CA/wKiom1XtOWfzOqV3AAFfWy5dmeY062.jpg "title=" 8.png " alt= "Wkiom1xtowfzoqv3aaffwy5dmey062.jpg"/>


6), enter the/usr/local/conf directory and locate the Server.xml file, which is the main configuration file for Tomcat:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/C7/wKioL1XtPNvw2eQcAAKTUekR1Xw984.jpg "title=" 9.png " alt= "Wkiol1xtpnvw2eqcaaktuekr1xw984.jpg"/>

Open the configuration file, you can see Tomcat has a local management port 8005, only allow log on locally, and can execute the shutdown instruction to shut down the Tomcat service:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/C7/wKioL1XtPYnSWptPAAIZsoQMuxQ064.jpg "title=" 10.png "alt=" Wkiol1xtpynswptpaaizsoqmuxq064.jpg "/>

Log on to local administration using Telnet, execute shutdown and view ports:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/CA/wKiom1XtO83SEKmEAAOsdqq_06U841.jpg "title=" 11.png "alt=" Wkiom1xto83sekmeaaosdqq_06u841.jpg "/>


7), create virtual directory/test, enable Tomcat virtual directory Access

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/CA/wKiom1XtP3mhn8NqAAC8e-H8X78659.jpg "title=" 1.jpg " alt= "Wkiom1xtp3mhn8nqaac8e-h8x78659.jpg"/>


Create a home page under the Tets directory index.jsp

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/C7/wKioL1XtRDKDfNq9AAFKCM98wSM464.jpg "title=" 12.png "alt=" Wkiol1xtrdkdfnq9aafkcm98wsm464.jpg "/>


Start Tomcat and access the test effect:


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/CB/wKiom1XtQpPRS7iMAAEwFKYBGMY137.jpg "title=" 13.png "alt=" Wkiom1xtqpprs7imaaewfkybgmy137.jpg "/>


Viewing the work directory, you can find the virtual directory test

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/C7/wKioL1XtRWyA3O-SAAFWtD0rGlY455.jpg "title=" 14.png "alt=" Wkiol1xtrwya3o-saafwtd0rgly455.jpg "/>



8), create a physical directory to enable Tomcat physical directory Access

[Email protected] tomcat]# mkdir/phy_test/[[email protected] tomcat]# mv/usr/local/tomcat/webapps/test//phy_test/ Test


Modify the configuration file to specify the physical directory location:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/CB/wKiom1XtRk2SnVPWAAER71BqW8Y541.jpg "title=" 16.png "alt=" Wkiom1xtrk2snvpwaaer71bqw8y541.jpg "/>

Test the syntax and restart Tomcat:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/CB/wKiom1XtRo_xlYyiAAREscbuO6c844.jpg "title=" 17.png "alt=" Wkiom1xtro_xlyyiaarescbuo6c844.jpg "/>


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/CB/wKiom1XtRsaTdRZvAANDGEaiSL8876.jpg "title=" 18.png "alt=" Wkiom1xtrsatdrzvaandgeaisl8876.jpg "/>


Access test:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/C8/wKioL1XtSVKBow8aAAGmbugS3Hg918.jpg "title=" 19.png "alt=" Wkiol1xtsvkbow8aaagmbugs3hg918.jpg "/>


5, the Comprehensive application-----jcenter Forum Construction

Install MySQL from CD

[email protected] ~]# yum install MySQL mysql-server-y


Start MySQL and configure the admin login password:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/CB/wKiom1XtSTyj-9SAAADkhXMyezI756.jpg "title=" 20.png "alt=" Wkiom1xtstyj-9saaadkhxmyezi756.jpg "/>

To create a database jcenter:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/C8/wKioL1XtS-GCeUsuAAEqxOE7f_4782.jpg "title=" 21.png "alt=" Wkiol1xts-gceusuaaeqxoe7f_4782.jpg "/>


Unpack Jcenter, upload directory to Tomcat's main site

[[email protected] ~]# unzip Javacenter_home_gbk.zip[[email protected] ~]# CD Javacenter_home_2.0_gbk/[[email protected ] javacenter_home_2.0_gbk]# MV upload//usr/local/tomcat/webapps/jcenter


To perform the Jcenter installation program via the browser:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/CC/wKiom1XtS1HjQz6NAAPmx-L_bfs646.jpg "title=" 22.jpg "alt=" Wkiom1xts1hjqz6naapmx-l_bfs646.jpg "/>

Fill in the database and related information, start the installation

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/CC/wKiom1XtS6_hH5h9AAHZT7zMe_E618.jpg "title=" 23.png "alt=" Wkiom1xts6_hh5h9aahzt7zme_e618.jpg "/>



650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/C8/wKioL1XtTw7D37S6AAESi1SoLk8293.jpg "title=" 25.png "alt=" Wkiol1xttw7d37s6aaesi1solk8293.jpg "/>


Installation Complete

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/C9/wKioL1XtTz6B-NOPAAGR4podTmA416.jpg "title=" 26.png "alt=" Wkiol1xttz6b-nopaagr4podtma416.jpg "/>


Go to Background management

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/C9/wKioL1XtT3SCZE0FAAJrkyMOE1I540.jpg "title=" 111. PNG "alt=" wkiol1xtt3scze0faajrkymoe1i540.jpg "/>


--------jcenter installation is complete ----------------


This article is from the "but evil Water Heart Pan" blog, please be sure to keep this source http://shmilyfl.blog.51cto.com/8897986/1692375

Tomcat building and basic application under Linux

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.