一个tomcat部署多个应用实例
-
安装JDK7
sudo apt-get install java7-jdk -
安装tomcat7
Tomcat7下载地址
http://mirror.bjtu.edu.cn/apache/tomcat/tomcat-7/v7.0.34/bin/找到apache-tomcat-7.0.34.tar.gz
解压 sudo tar xvzf apache-tomcat-7.0.34.tar.gz
移动tomcat sudo mv apache-tomcat-7.0.34 /data/game-web/启动tomcat
/data/game-web/apache-tomcat-7.0.34/bin/startup.sh
查看是否正常启动,tomcat 端口默认为 8080关闭tomcat
/data/game-web/apache-tomcat-7.0.34/bin/ shutdown.sh -
配置一个tomcat 部署多个应用实例
修改server.xml
Vi /data/game-web/apache-tomcat-7.0.35/conf/ server.xml找到
<Server port="8005" shutdown="SHUTDOWN">
修改为
<Server port="${tomcat.server.port}" shutdown="SHUTDOWN">找到
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
修改为
<Connector port="${tomcat.http.port}" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
找到
<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>修改为
<Host name="${tomcat.http. domainName}" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="${tomcat.http. domainName}_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" /><Context path="" docBase="${tomcat.http.weburl}" reloadable="true" crossContext="true" />
</Host> -
创建test-start.sh文件
test-start.sh文件内容如下:
rm -rf /data/game-web/apache-tomcat-7.0.35/work/*
# begin
export CATALINA_OPTS="
-Dtomcat.server.port=8005
-Dtomcat.http.port=8080
-Dtomcat.http. domainName =www.zqgame.com
-Dtomcat.http. weburl =/data/game-web/bw
-Xms1024m
-Xmx1024m
-XX:PermSize=128m -XX:MaxPermSize=256m
-XX:+HeapDumpOnOutOfMemoryError"
export CATALINA_PID="/data/game-web/apache-tomcat-7.0.35/tomcat-test.pid"
time /data/game-web/apache-tomcat-7.0.35/bin/catalina.sh start#end
如要启动多个 tomcat应用实例就在test-start.sh 文件内容,从 #begin开始到 #end 结束拷贝多修改即可
创建test-stop.sh文件,文件内容如下: -
创建test-stop.sh文件
test-stop.sh文件内容如下:
export JAVA_OPTS="-Dtomcat.server.port=8005"
export CATALINA_PID="/data/game-web/apache-tomcat-7.0.35/tomcat-test.pid"
/data/game-web/apache-tomcat-7.0.35/bin/catalina.sh stop 0 -force
欢迎搜索关注微信公众号 基础全知道 :JavaBasis ,第一时间阅读最新文章