Java+tomcat Multi-instance configuration

Source: Internet
Author: User
Tags stop script server port

Tomcat needs to work with the Java environment, so we need to install Java first (I'm using the java1.7.0 version here)

First, preparation: Download java1.7.0 compressed Package

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

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

Mkdir/usr/local/java
#创建jdk存放目录

Tar XF jdk-7u79-linux-x64.tar.gz
#解压jdk源码包

CP Jdk-8u121-linux-x64/usr/local/java

#将jdk源码包拷贝到指定目录, this directory is specified according to its own custom

2. Uninstalling the system-installed Java environment

Rpm-qa | grep java*
#查询已安装的有关java的rpm包

Yum Remove-y java*

#卸载java

3. Add Java variables to environment variables so that all users can use the

Vim/etc/profile

##### #JAVA #####

java_home=/usr/lcoal/java/jdk1.7.0_79

Path= $JAVA _home/bin/tools.jar: $JAVA _home/libdt.jar

Classpath=.: $JAVA _home/lib/tools.jar: $JAVA _home/lib/dt.jar

Export PATH java_home CLASSPATH catalina_home

3.1 Updating environment variables

Source/etc/porfile

See if Java is configured successfully

[Email protected] opt]# java-version
Java Version "1.7.0_79"
Java (TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot (TM) 64-bit Server VM (build 24.79-b02, Mixed mode)

Second, configure Tomcat (Tomcat decompression can be used)

2.1 Unzip the apache-tomcat-7.0.57.tar.gz and rename it to Tomcat_one Tomcat_two

Tar XF apache-tomcat-7.0.57.tar.gz
#解压tomcat压缩包

CP apache-tomcat-7.0.57 Tomcat_one

CP apache-tomcat-7.0.57 Tomcat_two

2.2 Put the test page you wrote into the Tomcat Web file directory

#tomcat_one index.jsp "This is Tomcat_one"

#tomcat_two index.jsp "This is Tomcat_two"

#将tomcat自带的欢迎页面删除

RM-RF tomcat_one/webapps/root/*

#tomcat_one

CP index.jsp Tomcat_one/webapps/root

#tomcat_tow

CP index.jsp Tomcat_one/webapps/root

2.3 Single-machine deployment multiple instances need to modify Tomcat ports

Vim/tomcat/conf/server.xml

<server port= "8005" shutdown= "Shutdown" >

<connector port= "8080" protocol= "http/1.1"

<connector port= "8009" protocol= "ajp/1.3" redirectport= "8443"/>

Tomcat default port is: 8005 8009 8080, if multiple tomcat is deployed on one machine need to modify port to prevent port conflict

8005: Remote Stop service port

8009: Apache can over AJP protocol access to Tomcat's 8009 port for AJP port.

8080:http Access Port

2.4 Start Service (each tomcat comes with a start-stop script)

#停止服务脚本

sh/tomcat/bin/shutdown.sh

#启动服务脚本

sh/tomcat/bin/startup.sh

2.5 Detailed configuration refer to the following Web page:

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

2.6 Installation configuration complete, test

http://localhost:8080

http://localhost:8081

Java+tomcat Multi-instance configuration

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.