目的:在服务器上安装一个tomcat实现多个应用的服务
步骤:修改$TOMCAT_HOME/conf/server.xml
内容:
<Server port="8005" shutdown="SHUTDOWN" debug="0">
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
debug="0"/>
<!-- Global JNDI resources -->
<GlobalNamingResources>
<!-- Test entry for demonstration purposes -->
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users -->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved">
</Resource>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
<Service name="Catalina"><!--名字可自定义,但是不能和其它相同-->
<!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 -->
<Connector port="8083"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" /><!--端口修改,不能相同-->
<!-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
<!--
<Connector port="8443"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" debug="0" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
<Connector port="8009"
enableLookups="false" redirectPort="8443" debug="0"
protocol="AJP/1.3" /><!--端口修改,不能相同-->
<Engine name="Catalina" defaultHost="localhost" debug="0"><!--名字可自定义,但是不能和其它相同-->
<!-- Global logger unless overridden at lower levels -->
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="catalina_log." suffix=".txt"
timestamp="true"/>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
debug="0" resourceName="UserDatabase"/>
<!-- Define the default virtual host
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="localhost" debug="0" appBase="/home/dqscdma/work/dest/webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false"><!--"/home/dqscdma/work/dest/webapps"此目录自己设定-->
<Context path="" docBase="dqis" debug="0" privileged="true" reloadable="true">
<Resource name="jdbc/DQSP" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/DQSP"><!--dqis改成自己存放的文档目录-->
<parameter><name>factory</name><value>org.apache.commons.dbcp.BasicDataSourceFactory</value></parameter>
<parameter><name>driverClassName</name><value>oracle.jdbc.driver.OracleDriver</value></parameter>
<parameter><name>url</name><value>jdbc:oracle:thin:@192.168.10.30:1521:itdata</value></parameter>
<parameter><name>username</name><value>wufeng</value></parameter>
<parameter><name>password</name><value>wufeng</value></parameter>
<parameter><name>maxActive</name><value>20</value></parameter>
<parameter><name>maxIdle</name><value>10</value></parameter>
<parameter><name>maxWait</name><value>-1</value></parameter>
<parameter><name>removeAbandoned</name><value>true</value></parameter>
<parameter><name>removeAbandonedTimeout</name><value>60</value></parameter>
<parameter><name>logAbandoned</name><value>true</value></parameter>
</ResourceParams>
</Context>
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>
</Host>
</Engine>
</Service>
<Service name="Catalina1"><!--名字可修改但是不能和上面相同-->
<!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 -->
<Connector port="8086"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" /><!--端口修改,不能相同-->
<!-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
<!--
<Connector port="8443"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" debug="0" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
<Connector port="8010"
enableLookups="false" redirectPort="8443" debug="0"
protocol="AJP/1.3" /><!--端口修改,不能相同-->
<Engine name="Catalina1" defaultHost="localhost" debug="0"><!--名字可修改但是不能和上面相同-->
<!-- Global logger unless overridden at lower levels -->
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="catalina_log." suffix=".txt"
timestamp="true"/>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
debug="0" resourceName="UserDatabase"/>
<!-- Define the default virtual host
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="localhost" debug="0" appBase="/home/dqscdma/work/dest/webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false"><!--"/home/dqscdma/work/dest/webapps"此目录自己设定-->
<Context path="" docBase="dqsp" debug="0" privileged="true" reloadable="true">
<Resource name="jdbc/DQSP" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/DQSP"><!--dqsp改成自己存放的文档目录-->
<parameter><name>factory</name><value>org.apache.commons.dbcp.BasicDataSourceFactory</value></parameter>
<parameter><name>driverClassName</name><value>oracle.jdbc.driver.OracleDriver</value></parameter>
<parameter><name>url</name><value>jdbc:oracle:thin:@192.168.10.30:1521:itdata</value></parameter>
<parameter><name>username</name><value>liuli</value></parameter>
<parameter><name>password</name><value>liuli</value></parameter>
<parameter><name>maxActive</name><value>20</value></parameter>
<parameter><name>maxIdle</name><value>10</value></parameter>
<parameter><name>maxWait</name><value>-1</value></parameter>
<parameter><name>removeAbandoned</name><value>true</value></parameter>
<parameter><name>removeAbandonedTimeout</name><value>60</value></parameter>
<parameter><name>logAbandoned</name><value>true</value></parameter>
</ResourceParams>
</Context>
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>
</Host>
</Engine>
</Service>
</Server>
想实现更多的应用服务添加相应的service即可,注意service name不能相同,端口不能相同 (免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)