JAVA + Tomcat multi-instance configuration, javatomcat instance

Source: Internet
Author: User

JAVA + Tomcat multi-instance configuration, javatomcat instance

Tomcat needs to be run in combination with the java environment, so we need to install java first (java 1.7.0 is used here)

I. Preparations: Download The java1.7.0 compressed package

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

1. decompress the downloaded JDK source code package and copy it to the specified directory.

1 mkdir/usr/local/java2 # create jdk storage directory 3 tar xf jdk-7u79-linux-x64.tar.gz4 # unzip jdk source package 5 cp jdk-8u121-linux-x64/usr/local/java6 # copy jdk source package to the specified directory, this directory is specified according to your own habits.

2. Uninstall the JAVA environment installed by the System

1 rpm-qa | grep java * 2 # query installed rpm packages for java 3 yum remove-y java * 4 # Uninstall java

3. Add the JAVA variable to the environment variable so that all users can use it.

1 vim /etc/profile2 3 ######JAVA#####4 JAVA_HOME=/usr/lcoal/java/jdk1.7.0_795 PATH=$JAVA_HOME/bin/tools.jar:$JAVA_HOME/libdt.jar6 CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar7 export PATH JAVA_HOME CLASSPATH CATALINA_HOME

3.1 update Environment Variables

source /etc/porfile

Check whether java is configured successfully

1 [root@localhost opt]# java -version2 java version "1.7.0_79"3 Java(TM) SE Runtime Environment (build 1.7.0_79-b15)4 Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

2. Configure tomcat (tomcat can be used after decompression)

2.1decompress apache-tomcat-7.0.57.tar.gz and rename it tomcat_one tomcat_two

1 tar xf apache-tomcat-7.0.57.tar.gz2 # unzip tomcat compressed package 3 cp apache-tomcat-7.0.57 tomcat_one4 cp apache-tomcat-7.0.57 tomcat_two

2.2 Add the self-written test page to the tomcat webpage file directory

1 # tomcat_one index. jsp "this is tomcat_one" 2 # tomcat_two index. jsp "this is tomcat_two" 3 # Delete the welcome page of tomcat 4 rm-rf tomcat_one/webapps/ROOT/* 5 # tomcat_one6 cp index. jsp tomcat_one/webapps/ROOT7 # tomcat_tow8 cp index. jsp tomcat_one/webapps/ROOT

2.3 tomcat port needs to be modified to deploy multiple instances on a single machine

1 vim/tomcat/conf/server. xml2 <Server port = "8005" shutdown = "SHUTDOWN"> 3 <Connector port = "8080" protocol = "HTTP/1.1" 4 <Connector port = "8009" protocol =" AJP/1.3 "redirectPort =" 8443 "/>
5. Modify the fields of the preceding 2-4 rows and set the port to the one you need.

The default tomcat port is 8005 8009 8080. If multiple tomcat servers are deployed on one machine, you need to modify the port to prevent port conflict.

8005: remote service Stop port

8009: Port AJP: APACHE can access TOMCAT port 8009 through the AJP protocol.

8080: http access port

2.4 start the service (each tomcat has its own start and stop scripts)

1 # Stop Service Script 2 sh/tomcat/bin/shutdown. sh3 # Start Service script 4 sh/tomcat/bin/startup. sh

2.5 for detailed configuration, refer to the following webpage:

http://xxs673076773.iteye.com/blog/1134805

2.6 The installation and configuration are complete, and the test is complete.

Http: // localhost: 8080

Http: // localhost: 8081

 

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.