第一步:修改 $TOMCAT_HOME\conf 下的server.xml文件
1.复制节点 ,粘贴新增节点
2.删除掉新增节点下的<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />节点
3.新增Service节点的name属性修改为Catalina1
4.新增Service节点的Connector节点port属性修改为8081(根据机器配置未占用端口)
5.新增Service节点的Engine节点的name修改为Catalina1
6.新增Service节点的Engine节点的Host节点appBase属性修改为webapps1
7.Engine节点下的Host节点中添加:<context docbase path reloadable source></context>,例子中helloMVC是项目名。(解决了我访问新加项目中jsp等页面文件404的问题)
不用项目名称访问:把中的contex中的path属性设为“”,端口改为80,可直接ip或域名访问。
第二步:$TOMCAT_HOME 路径下新建文件夹webapps1,里面放要发布的项目 .war文件
第三步: 复制$TOMCAT_HOME\confi目录下的Catalina生成副本 ,并命名为Catalina1
第四步:启动:/opt/tomcat/bin/catalina.sh
参考自:
$TOMCAT_HOME 路径下新建文件夹webapps1,里面放要发布的项目 .war文件
下面附上我的server.xml 例子,其中Catalina1是域名访问,不用项目名访问。
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<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" />
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
<!--后面是自己编辑的-->
<Service name="Catalina1">
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="14000"
redirectPort="8443" />
<Engine name="Catalina1" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps1"
unpackWARs="true" >
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context docBase="Personal" path="" reloadable="true" />
</Host>
</Engine>
</Service>
<Connector port="9997" protocol="HTTP/1.1"
connectionTimeout="14000"
redirectPort="8443" />
<Engine name="Catalina2" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps2"
unpackWARs="true" >
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context docBase="helloMVC" path="/helloMVC" reloadable="true" source="org.eclipse.jst.jee.server:helloMVC"/>
</Host>
</Engine>
<Service name="Catalina3">
<Connector port="9996" protocol="HTTP/1.1"
connectionTimeout="14000"
redirectPort="8443" />
<Engine name="Catalina3" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps3"
unpackWARs="true" >
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context docBase="ProvinceCity_json" path="/ProvinceCity_json" reloadable="true" source="org.eclipse.jst.jee.server:ProvinceCity_json"/>
</Host>
</Engine>
</Service>
<Service name="Catalina4">
<Connector port="9995" protocol="HTTP/1.1"
connectionTimeout="14000"
redirectPort="8443" />
<Engine name="Catalina4" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps4"
unpackWARs="true" >
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context docBase="web1" path="/web1" reloadable="true" source="org.eclipse.jst.jee.server:web1"/>
</Host>
</Engine>
</Service>
<Service name="Catalina5">
<Connector port="9994" protocol="HTTP/1.1"
connectionTimeout="14000"
redirectPort="8443" />
<Engine name="Catalina5" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps5"
unpackWARs="true" >
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context docBase="province" path="/province" reloadable="true" source="org.eclipse.jst.jee.server:province"/>
</Host>
</Engine>
</Service>
</Server>