Run the service on Tom

Source: Internet
Author: User

1. CD/usr/local/tomcat/

2. You can create several directories, called/tomcat/webapps, and create the libincia directory in webapps, and in this directory, create/WEB-INF and create/classes and/lib respectively under the WEB-INF, Which means we want to deploy a service.

Mkdir/tomcat/webapps-PV

CD webapps

Mkdir libincia

[[Email protected] libinlinoleic] # tree WEB-INF/
WEB-INF/
── Classes
── Lib

2 directories, 0 files

3. Create a file named index. jsp under the libincia directory (note the Directory) and check the effect.

650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_1411997179otMY.png "width =" 488 "Height =" 341 "/>

4. Configure the main configuration file of Tomcat, which defines a new host or a new context to include the modified one.

Define a new host named libincla.clarinet.com

<Host name = "libincla.clarinet.com" appbase = "/tomcat/webapps"
Unpackwars = "true" autodeploy = "true">
</Host>

The default host is libincla.clarinet.com.

<Engine name = "Catalina" defaulthost = "libincla.clarinet.com">

Disable and start Catalina. Sh to view the effect

650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_14119971854hoH.png "width =" 523 "Height =" 374 "/>

Scenario 2,

Here, the default host of the engine is modified in the previous operation. In this case, what should we do if we want to use the libincia service just defined and localhost?

Cut the/tomcat/webapps/libingroovy directory to/usr/local/tomcat/webapps.

[[Email protected] libincia] # cp-r/tomcat/webapps/libincia // usr/local/tomcat/webapps/

Edit/usr/local/tomcat/CONF/server again. XML file, and change the engine host back to localhost, remove the host defined below, and Catalina again. sh stop & Catalina. try sh start.

650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_1411997191cJTo.png "width =" 525 "Height =" 280 "/>

And through

650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_1411997208R9FS.png "width =" 531 "Height =" 232 "/> you can access this defined service,

650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_1411997225CuWT.png "width =" 538 "Height =" 253 "/>

In addition, all the statuses of the service are defined in the server status on the home page.

650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_1411997239DUuJ.png "width =" 552 "Height =" 267 "/> if this shows JVM running what are the heap memory of Java in?

If you do not want to deploy a new service by modifying the configuration file, you can

650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_1411997276njiT.png "width =" 553 "Height =" 375 "/> Add a new one directly by adding a button service options. This is a hot deployment of Tomcat, and this method is not recommended.

Scenario 3,

Write a script for Tomcat to control it, or add it to the service list to enable automatic startup.

#! /Bin/sh
# Tomcat init script for Linux
#
# Chkconfig 2345 19 88
# Java_opts = '-xms64m-xmx128m'
Java_home =/usr/Java/lastest
Catalina_home =/usr/local/tomcat
Export java_home catalina_home

Case $1 in
Start)
Exec $ catalina_home/bin/Catalina. Sh start ;;
Stop)
Exec $ catalina_home/bin/Catalina. Sh stop ;;
Restart)
Exec $ catalina_home/bin/Catalina. Sh stop
Sleep 3
Exec $ catalina_home/bin/Catalina. Sh start ;;
*)
Echo "make start or stop or restart"
Exit 1
;;
Esac

Then you can use the script to run and control tomcat.

[[Email protected] libincia] # service Tomcat stop
Using catalina_base:/usr/local/tomcat
Using catalina_home:/usr/local/tomcat
Using catalina_tmpdir:/usr/local/tomcat/temp
Using jre_home:/usr/Java/lastest
Using classpath:/usr/local/tomcat/bin/Bootstrap. jar:/usr/local/tomcat/bin/tomcat-juli.jar
/Usr/local/tomcat/bin/Catalina. sh: Line 437:/usr/Java/lastest/bin/Java: no such file or directory

[[Email protected] libincia] # service Tomcat start (Tomcat started)
Using catalina_base:/usr/local/tomcat
Using catalina_home:/usr/local/tomcat
Using catalina_tmpdir:/usr/local/tomcat/temp
Using jre_home:/usr/Java/lastest
Using classpath:/usr/local/tomcat/bin/Bootstrap. jar:/usr/local/tomcat/bin/tomcat-juli.jar

If you want to define a new service in Tomcat, You need to define a new host. If you want to define an application instance in the service, you need to define a new context in the host, however, by default, in the Java definition, a service root directory is used to store the main configuration file of the service (note that this service is used ), each application is defined in another directory in the root directory.

Description of the reference context document:

Context component:
In some sense, context is similar to the path alias in Apache. A context definition is used to identify a web application in a tomcat instance. the following definition:
<! -- Tomcat root context -->
<Context Path = "" docbase = "/web/webapps"/>
<! -- Buzzin webapp -->
<Context Path = "/BBS"
Docbase = "/web/Threads/BBS"
Reloadable = "true">
</Context>
<! -- Chat Server -->
<Context Path = "/chat" docbase = "/web/chat"/>
<! -- Darian Web -->
<Context Path = "/Darian" docbase = "Darian"/>

In tomcat6, each context definition can also be performed using a separate XML file. The directory of the file is $ catalina_home/CONF/<engine Name>/<Host Name>. The XML elements in context can be loader, Manager, realm, resources, and watchedresource.

Common attributes are defined as follows:
1) docbase: The storage location of the corresponding web application. You can also use the relative path. The starting path is the path defined by appbase in the host to which the context belongs. Remember, the path name of docbase cannot be included with the path name defined in appbase of the corresponding host. For example, if appbase is deploy, docbase cannot be the name of the deploy-BBs class;
2) path: URI relative to the root path of the Web server. If it is null, it indicates the root path of the webapp. If context is defined in a separate XML file, this attribute does not need to be defined;
3) reloadable: whether to allow re-loading the web application class related to this context; the default value is false;

 

Scenario 3: deploy an application that can be applied.

3.1

For example, visit http://www.libincla.com/jct?forum

So Path = "/jct", docbase = "jct"

 

Prerequisites: MySQL is installed because the database is required to retrieve data.

MySQL has been deployed in this environment

[[Email protected] TMP] # service mysqld start
Starting MySQL... [OK]
[[Email protected] TMP] # MySQL
Welcome to the MySQL monitor. commands end with; or \ G.
Your MySQL connection ID is 2
Server version: 5.5.36-mariadb-log mariadb Server

Copyright (c) 2000,201 3, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.

Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.

Mysql>

At the same time, you can create a login user in MySQL, for example, jctuser and the password is jctpasswd.

Mysql> grant all on jct. * to [email protected] identified by 'jctpasswd'
->;
Query OK, 0 rows affected (0.01 Sec)

Mysql> grant all on jct. * to [email protected] identified by 'jctpasswd'
->;
Query OK, 0 rows affected (0.01 Sec)
Mysql> Create Database jct;
Query OK, 1 row affected (0.03 Sec)

Mysql> flush privileges;
Query OK, 0 rows affected (0.00 Sec)

This environment is intended to deploy an application called javacenter_home.

[[Email protected] TMP] # ls javacenter_home_2.0_gbk.tar.bz2
Javacenter_home_2.0_gbk.tar.bz2

Edit the main configuration file of Tomcat and define a new host in the engine, as shown in figure

<Host name = "www.libincla.com" appbase = "/tomcat/webapps"
Unpackwars = "true" autodeploy = "true">
<Context Path = "/jct" docbase = "jct"/>

Decompress the javacenter service.

[[Email protected] TMP] # tar xf javacenter_home_2.0_gbk.tar.bz2

Then place it in the/tomcat/webapps directory named jct.

[[Email protected] TMP] # mv javacenter_home_2.0_gbk/tomcat/webapps/jct

JPS allows you to view

Then restart the access.

650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_14119972807KSS.png "width =" 551 "Height =" 164 "/>: I have been unable to cope with the problem. I forgot to add port 8080 !)

Edit the config. properties file and add

[[Email protected] libincia] # cd/tomcat/webapps/jct/
[[Email protected] jct] # ls
Admin app. jsp config. properties crossdomain. XML editor. jsp help. jsp install link. jsp network. jsp space. jsp userapp. jsp
Admincp. jsp attachment contact. jsp data errors image invite. jsp magic. jsp RSS. jsp template WEB-INF
API avatar. jsp CP. jsp do. jsp favicon. ICO index. jsp Javascript. jsp META-INF source theme XMLRPC. jsp
[[Email protected] jct] # Vim con
Config. properties contact. jsp
[[Email protected] jct] # Vim con
Config. properties contact. jsp
[[Email protected] jct] # Vim config. Properties

650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_1411997293YHFk.png "width =" 546 "Height =" 327 "/>

Modify the user, password, and Database Name of the database respectively.

650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_1411997311WlqH.png "width =" 550 "Height =" 347 "/> here for this application for deployment, install must be added to the URL.

Enter information

650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_1411997321HYjc.png "width =" 552 "Height =" 447 "/>

After all the configurations have been completed, you will be asked to set the account of the current system.

650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_1411997333mGq2.png "width =" 558 "Height =" 309 "/>

650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_1411997345sc82.png "width =" 561 "Height =" 312 "/>

The following figure is displayed:
650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_1411997369z9VF.png "width =" 562 "Height =" 341 "/>

You can also modify the Avatar.

650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_1411997387I8OF.png "width =" 565 "Height =" 217 "/>

If Tom does not directly respond to the client, nginx will reverse proxy.

Let Tom work in the in-process model,That is, the response model of different processes in a host.Below ::

650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_1411997398TCJR.png "width =" 580 "Height =" 374 "/>

Steps:

1. Start nginx, define the nginx configuration file, and add the following entries:

650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_1411997408bKHL.png "width =" 589 "Height =" 223 "/>

Edit the file, restart nginx, and access the www.libincla.com/jct/space.jspfile.

650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_1411997422pEGu.png "width =" 560 "Height =" 489 "/>

If I only request the homepage, The nginx response will not be forwarded to the backend.

650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_1411997441yilh.png "width =" 569 "Height =" 296 "/>

Upload the log of nginxto record the following information. The existence of the .gif/animated/. JPG file causes the image to be unresponsive.

650) This. width = 650; "style =" border-right-0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201409/29/6249823_1411997482CqTD.png "width =" 882 "Height =" 250 "/>

Run the service on Tom

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.