日期:2014-05-16  浏览次数:20619 次

Linux下多个tomcat环境的搭建

(一)、先修改tomcatB的server.xml配置文件中三个端口号,不一样即可(没被占用)

??? (1)、<Server port="8005" shutdown="SHUTDOWN">
????(2)、<Connector port="8080" protocol="HTTP/1.1"
?????????????? connectionTimeout="20000"
?????????????? redirectPort="8443" />
??? (3)、<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

<Server port="8005" shutdown="SHUTDOWN">

  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>
  <Service name="Catalina">
  
    <Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />
   
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

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

      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
      </Host>
    </Engine>
  </Service>
</Server>

?

(二)、修改/etc/profile文件,添加CATALINA_2_HOME=/usr/local/tomcatB并export ,改好后执行source /etc/profile重启profile?

JAVA_HOME=/usr/java/jdk1.6.0_29
CLASSPATH=.:$JAVA_HOME/lib/tools.jar
PATH=$JAVA_HOME/bin:$PATH
CATALINA_HOME=/usr/local/tomcatA
CATALINA_2_HOME=/usr/local/tomcatB
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL JAVA_HOME CLASSPATH CATALINA_HOME CATALINA_2_HOME

?

(三)、在tomcatB的startup.sh和shutdown.sh中添加export CATALINA_HOME=$CATALINA_2_HOME(在while前)

(四)好了,启动tomcatB,执行netstat -an可以看到你所设置的tomcatB端口已被使用,部署成功!!!