标签:cat ebs contex tls UNC 拷贝 work code server
java不同于php,单个站点更新维护都会影响到其他站点,一般都会将几个站点放在一个实例下。今天全称演示单台服务器如何配置多个tomcat实例。
tomcat:/usr/local/tomcat
a.ttlsa.com
站点程序:/data/site/a.ttlsa.com
端口:8080
b.ttlsa.com
站点程序:/data/site/b.ttlsa.com
端口:8081
在tomcat安装目录下创建 a.ttlsa.com、b.ttlsa.com,并且将 conf、logs、webapp、temp、work 目录拷贝到这两个目录,然后tomcat安装目录只需要留下bin、a.ttlsa.com、b.ttlsa.com、lib这4个目录即可。配置后的目录结构如下:
# pwd
/usr/local/tomcat
# tree -d -L 2
├── bin
├── a.ttlsa.com
│ ├── conf
│ ├── logs
│ ├── target
│ ├── temp
│ ├── webapp
│ └── work
├── lib
└── b.ttlsa.com
├── conf
├── logs
├── temp
├── webapp
└── work
vim /usr/local/tomcat/a.ttlsa.com/conf/server.xml
//注释ajp
<!-- <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> -->
//server端口8005改为8001
<Server port="8001" shutdown="SHUTDOWN">
//在<Engine name="Catalina" defaultHost="localhost">增加host配置,如下
<Host name="a.ttlsa.com" appBase="/data/site/a.ttlsa.com"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="" reloadable="true">
<valve className="org.apache.catalina.valves.RemoteAddrValve" />
</Context>
</Host>
vim /usr/local/tomcat/a.ttlsa.com/conf/server.xml
//注释ajp
<!-- <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> -->
//server端口8005改为8002
<Server port="8002" shutdown="SHUTDOWN">
//在<Engine name="Catalina" defaultHost="localhost">增加host配置,如下
<Host name="b.ttlsa.com" appBase="/data/site/b.ttlsa.com"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="" reloadable="true">
<valve className="org.apache.catalina.valves.RemoteAddrValve" />
</Context>
</Host>
在 a.ttlsa.com、b.ttlsa.com 目录下分别创建启动脚本 tomcat.sh
#!/bin/sh
# AuthName:凉白开
# Website:http://www.ttlsa.com
# DateTime:2014-05-04
# description: 启动tomcat多实例.
. /etc/init.d/functions
RETVAL=$?
# tomcat实例目录
export CATALINA_BASE="$PWD"
# tomcat安装目录
export CATALINA_HOME="/usr/local/tomcat-7.0.50"
# 可选
export JVM_OPTIONS="-Xms128m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=512m"
case "$1" in
start)
if [ -f $CATALINA_HOME/bin/startup.sh ];then
echo $"Start Tomcat"
$CATALINA_HOME/bin/startup.sh
fi
;;
stop)
if [ -f $CATALINA_HOME/bin/shutdown.sh ];then
echo $"Stop Tomcat"
$CATALINA_HOME/bin/shutdown.sh
fi
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
;;
esac
exit $RETVAL
a.ttlsa.com、b.ttlsa.com 目录下分别执行一下:chmod a+x tomcat.sh
cd /usr/local/tomcat/a.ttlsa.com/
#### 启动
./tomcat.sh start
#### 关闭
./tomcat.sh stop
cd /usr/local/tomcat/a.ttlsa.com/
#### 启动
./tomcat.sh start
#### 关闭
./tomcat.sh stop
备注:一定需要 cd 到 tomcat.sh 的当前目录下执行才可以
标签:cat ebs contex tls UNC 拷贝 work code server
原文地址:https://www.cnblogs.com/cy-8593/p/12358251.html