Objective: To install tomcat on a server to implement services for multiple applications
Step: Modify $ TOMCAT_HOME/conf/server. xml
Content:
<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
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"> <! -- The name can be customized, but cannot be the same as others -->
<! -- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 -->
<Connection port = "8083"
MaxThreads = "150" minSpareThreads = "25" maxSpareThreads = "75"
EnableLookups = "false" redirectPort = "8443" acceptCount = "100"
Debug = "0" connectionTimeout = "20000"
DisableUploadTimeout = "true"/> <! -- Port modification, cannot be the same -->
<! -- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
<! --
<Connection 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 -->
<Connection port = "8009"
EnableLookups = "false" redirectPort = "8443" debug = "0"
Protocol = "AJP/1.3"/> <! -- Port modification, cannot be the same -->
<Engine name = "Catalina" defaultHost = "localhost" debug = "0"> <! -- The name can be customized, but cannot be the same as others -->
<! -- 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: The XML Schema validation will not work with Xerces 2.2.
-->
<Host name = "localhost" debug = "0" appBase = "/home/dqtd-scdma/work/dest/webapps"
UnpackWARs = "true" autoDeploy = "true"
XmlValidation = "false" xmlNamespaceAware = "false"> <! -- "/Home/dqscdma/work/dest/webapps" this directory is set by yourself -->
<Context path = "" docBase = "dqis" debug = "0" privileged = "true" reloadable = "true">
<Resource name = "jdbc/DQSP" auth = "Container" type = "javax. SQL. DataSource"/>
<ResourceParams name = "jdbc/DQSP"> <! -- Change dqis to the directory of your stored documents -->
<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"> <! -- The name can be modified but cannot be the same as the above -->
<! -- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 -->
<Connection port = "8086"
MaxThreads = "150" minSpareThreads = "25" maxSpareThreads = "75"
EnableLookups = "false" redirectPort = "8443" acceptCount = "100"
Debug = "0" connectionTimeout = "20000"
DisableUploadTimeout = "true"/> <! -- Port modification, cannot be the same -->
<! -- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
<! --
<Connection 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 -->
<Connection port = "8010"
EnableLookups = "false" redirectPort = "8443" debug = "0"
Protocol = "AJP/1.3"/> <! -- Port modification, cannot be the same -->
<Engine name = "Catalina1" defaultHost = "localhost" debug = "0"> <! -- The name can be modified but cannot be the same as the above -->
<! -- 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: The XML Schema validation will not work with Xerces 2.2.
-->
<Host name = "localhost" debug = "0" appBase = "/home/dqtd-scdma/work/dest/webapps"
UnpackWARs = "true" autoDeploy = "true"
XmlValidation = "false" xmlNamespaceAware = "false"> <! -- "/Home/dqscdma/work/dest/webapps" this directory is set by yourself -->
<Context path = "" docBase = "dqsp" debug = "0" privileged = "true" reloadable = "true">
<Resource name = "jdbc/DQSP" auth = "Container" type = "javax. SQL. DataSource"/>
<ResourceParams name = "jdbc/DQSP"> <! -- Change dqsp to the directory of your stored documents -->
<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>
Add the corresponding service to more application services. Note that the service name cannot be the same and the port cannot be the same.