在一个tomcat下面布置2个项目
项目的访问路径:
http://localhost:8081/
http://localhost:8082/
1.建立两个站点(虚拟目录,目录中必须包含必要的配置文件WEB-INF)
2.修改tomcat配置文件server.xml,在server下,放置多个service即可。在service的平级上 添加如下配置:
<Service name="Catalina2"> <Connector port="8082" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8"/> <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="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" /> <Context path="" reloadable="true" docBase="D:/Environments/webSite2" workDir="D:/Environments/webSite2/work"></Context> </Host> </Engine> </Service>
3.启动tomcat