Have you ever thought about being on the same server and opening a few more tomcat at the same time?

Source: Internet
Author: User

Tomcat is often used to run Java projects as a running environment for many Java projects. and a server that only runs a tomcat service is a waste of resources, so, we can run multiple Tomcat service processes on the same server, each corresponding to a different port. To run multiple Java projects.
Here's how to configure it to start multiple tomcat at the same time.

The tools used are WINSCP, putty, CentOS6.5 installed Linux.

1, as I said in the previous article, first install the JDK, and configure the JDK environment.

After you connect the server with putty, use Vim/etc/profile to modify the environment variables.

(I'm here to use the jdk-8u131-linux-i586 version)

Export PATH USER LOGNAME MAIL HOSTNAME histsize Histcontrol

The specific content can be written in this sentence, note that the middle is the English colon delimiter, the hand hit the path is easy to hit the wrong way, you can use WINSCP open/etc/profile This file, directly copied into the editor

java_home=/usr/java/jdk1.8.0_131

Jre_home= $JAVA _home/jre

Path= $PATH: $JAVA _home/bin: $JRE _home/bin

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

Export Java_home jre_home PATH CLASSPATH

# # # #tomcat1 # #

# (here usr I wrote Urs, so groping for a long time can not start the first)

Export Catalina_base=/usr/local/tomcats/tomcat7-1

Export Catalina_home=/usr/local/tomcats/tomcat7-1

Export Tomcat_home=/usr/local/tomcats/tomcat7-1

# # # #tomcat2 # #

#这其中 $CATALINA _2_base and $catalina_2_home later modified

#tomcat的bin目录的文件catalina. Sh useful to

Export Catalina_2_base=/usr/local/tomcats/tomcat7-2

Export Catalina_2_home=/usr/local/tomcats/tomcat7-2

Export Tomcat_2_home=/usr/local/tomcats/tomcat7-2

2, modify the configuration of Tomcat, the first Tomcat do not have to make changes, modify the second tomcat, if there are multiple, then the first one without modification, the rest will be.
Modify/usr/local/tomcats/tomcat7-2/bin/catalina.sh with WINSCP

(Modify this file to add the following)

------------------------------------------------------------------
Export catalina_base= $CATALINA _2_base
Export Catalina_home= $CATALINA _2_home
-------------------------------------------------------------------

The first Tomcat server.xml file configuration item was written with an end tag </HOST> so starting Tomcat without an error, turning off Tomcat has been an error, very strange. I thought there was something wrong with the configuration. (You can configure the project to be published, change path, or change the name of the item you entered when you accessed the item in the Address bar.) )

3, modify the Tomcat listening port, to avoid the port consumption duplication can not start. As above, the first one does not have to be modified, the default 8080, and the rest to be modified. If the gitlab,8080 port is installed, you can change the 8080 to 8081 or any other unused port.

Open server.xml for editing with WINSCP

The path to the second Tomcat is/usr/local/tomcats/tomcat7-2/conf/server.xml

(Modify the configuration file, modify the following content)
-------------------------------------------------------------------------------------------

#8005修改成9005

<server port= "9005" shutdown= "Shutdown" >
#8080修改成8082

<connector port= "8082" protocol= "http/1.1"
connectiontimeout= "20000"
redirectport= "8443"/>
#8009修改成9009

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

After modifying the upper port, add an open port to the file/etc/sysconfig/iptables of the firewall and use the service iptables restart to restart the firewall.

4, OK, to this can be, respectively into the bin directory toncat1,tomcat2, start Tomcat. You will find that two Tomcat service processes were started, corresponding to the 8081,8082 port. Run more tomcat at the same time by referencing this configuration. Run Tomcat in Linux using the sh startup.sh command, turn off Tomcat using the sh shutdown.sh command.

5, in the configuration process, it is important to note that the configuration environment variables do not write the wrong path, the location of the configuration can be used for reference in my position. Modifying the configuration of the catalina.sh file can be written at the beginning. While modifying the port of the Server.xml file, be careful not to repeat with the other ports, causing conflicts, and after modifying the port, the firewall should also configure the appropriate port, and restart the firewall.

Have you ever thought about being on the same server and opening a few more tomcat at the same time?

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.