tomcat多端口发布项目

    一个tomcate是可以在不同的端口同时发布项目的,同时一个端口有可以同时发布多个项目,下面给出一个server.xml配置的例子(貌似不能添加中文注释)

<?xml version='1.0' encoding='utf-8'?>

<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" />
	<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
	<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />


	<GlobalNamingResources>
		<!-- 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"
		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">
				<!--向8080端口添加项目-->
				<Context path="" docBase="/home/sxdkj/project/support" reloadable="true" crossContext="true"/>
				<Context path="/game-stat" docBase="/home/sxdkj/project/game-stat" reloadable="true" crossContext="true"/>
				<Context path="/gm" docBase="/home/sxdkj/project/gm" reloadable="true" crossContext="true"/>
				<Context path="/gm-xh" docBase="/home/sxdkj/project/gm-xh" reloadable="true" crossContext="true"/>
				<!--向logs目录中打印日志-->
				<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
			</Host>
		</Engine>
	</Service>

	<!--发布第二个端口,这个端口里可以发布多个项目-->
	<Service name="Catalina2">
		<Connector port="9001" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
		<Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
		<Engine name="Catalina2" defaultHost="localhost">
			<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
			<Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">	
				<!--向9001端口添加项目-->
				<Context path="" docBase="/home/sxdkj/project/tencent-order" reloadable="true" crossContext="true"/>
				<!--向logs目录中打印日志-->
				<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
			</Host>
		</Engine>
	</Service>
</Server>

 

你可能感兴趣的:(tomcat)