Tomcat 7 deploys two projects by setting different ports _tomcat

Source: Internet
Author: User
Tags port number tomcat log4j

The method described in this article is implemented by adding a different port-number approach. The method is as follows:

1, modify ... /tomcat/conf/server.xml, the original code is as follows:

<service name= "Catalina" >

 <connector connectiontimeout= "20000" port= "8080" protocol= "http/1.1" redirectport= "8443"/>

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

 <Engine defaulthost= "localhost" name= "Catalina" >

 <realm classname= "Org.apache.catalina.realm.LockOutRealm" >
 <realm classname= "Org.apache.catalina.realm.UserDatabaseRealm" resourcename= "Userdatabase"/>
 < /realm>

  
 

2, add a new port number, the code is as follows:

Note ModifyService name; Connector port; Engine name; Host appBase

<service name= "Catalina1" >

 <connector connectiontimeout= "20000" port= "8090" protocol= "http/1.1" redirectport= "8443"/>

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

 <Engine defaulthost= "localhost" name= "Catalina1" >

 <realm classname= "Org.apache.catalina.realm.LockOutRealm" >
 <realm classname= "Org.apache.catalina.realm.UserDatabaseRealm" resourcename= "Userdatabase"/>
 </Realm>

  
 

3, create a directory

A. Create the directories that need to be deployed ../Tomcat/webapps1 and copy the items that need to be deployed to the directory;

B. Creating a configuration file directory../Tomcat/conf/Catalina1/localhost

4, modify the project code

In my attempt to find a more error-prone place, is the best modification web.xml and log4j.properties configuration files.

Where web.xml the file needs to be added webAppRootKey , the code is as follows:

Upper node is Web-app
<context-param>
 <param-name>webAppRootKey</param-name>
 < Param-value>mos_ms.root</param-value>
 </context-param>

Log4j.properties, the modified log4j.appender.org.apache.log4j.DailyRollingFileAppender.File value, the code is as follows:

Specific location customization, but need to be
Log4j.appender.a=org.apache.log4j.dailyrollingfileappender 
in ${catalina1.home} Log4j.appender.a.file=${catalina1.home}/logs/gyl_log/purepro_

5, make the corresponding changes

Startup Tomcat,webapps directory and WEBAPPS1 directory application will be started, can be based on different ports to access the inside of the project; Assuming the project name is MyApp, for the above changes we can use the following address to access: http://localhost : 8080/myapp or HTTP://LOCALHOST:8090/MYAPP.

Summarize

The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring certain help, if you have questions you can message exchange.

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.