配置多实例目录:
安装好tomcat后,创建三个实例目录,将主站点的:conf、 work 、temp、logs目录分别复制到3个实例目录下。
1 [[email protected] tomcat]# mkdir {bbs.fox.com,www.fox.com,e-mail.fox.com} 2 [[email protected] tomcat]# cp -r conf logs temp work ./bbs.fox.com 3 [[email protected] tomcat]# cp -r conf logs temp work ./www.fox.com 4 [[email protected] tomcat]# cp -r conf logs temp work ./e-mail.fox.com
1 [[email protected] tomcat]# pwd 2 /usr/local/tomcat 3 [[email protected] tomcat]# tree -d -L 2 4 . 5 ├── bbs.fox.com 6 │ ├── conf 7 │ ├── logs 8 │ ├── temp 9 │ └── work 10 ├── bin 11 ├── conf 12 │ └── Catalina 13 ├── e-mail.fox.com 14 │ ├── conf 15 │ ├── logs 16 │ ├── temp 17 │ └── work 18 ├── lib 19 ├── logs 20 ├── temp 21 ├── webapps 22 │ ├── docs 23 │ ├── examples 24 │ ├── host-manager 25 │ ├── manager 26 │ └── ROOT 27 ├── work 28 │ └── Catalina 29 └── www.fox.com 30 ├── conf 31 ├── logs 32 ├── temp 33 └── work
修改实例的配置文件server.xml:
1 bbs.fox.com 2 [[email protected] tomcat]# cat bbs.fox.com/conf/server.xml 3 <Server port="8091" shutdown="SHUTDOWN"> 4 <Connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> 5<Host name="localhost" appBase="/usr/local/Application/bbs.fox.com" unpackWARs="true" autoDeploy="true">
1 www.fox.com 2 [[email protected] tomcat]# cat www.fox.com/conf/server.xml 3 <Server port="8092" shutdown="SHUTDOWN"> 4 <Connector port="8082" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> 5 <Host name="localhost" appBase="/usr/local/Application/www.fox.com" unpackWARs="true" autoDeploy="true">
1 e-mail.fox.com 2 [[email protected] tomcat]# cat e-mail.fox.com/conf/server.xml 3 <Server port="8093" shutdown="SHUTDOWN"> 4 <Connector port="8083" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> 5 <Host name="localhost" appBase="/usr/local/Application/e-mail.fox.com" unpackWARs="true" autoDeploy="true">
多实例启动脚本:
在实例目录下分别创建启动脚本(记得给权限chmod +x)
1 [[email protected] bbs.fox.com]# cat bbs.tomcat 2 #!/bin/bash 3 #chkconfig: 2345 96 14 4 #bbs.fox.com 5 export JAVA_HOME=/usr/local/jdk 6 export JAVA_HOME CATALINA_HOME 7 export CATALINA_HOME=/usr/local/tomcat 8 export CATALINA_BASE="/usr/local/tomcat/bbs.fox.com" 9 export JAVA_OPTS=‘-Xms64m -Xmx128m‘ 10 case "$1" in 11 start) 12 $CATALINA_HOME/bin/startup.sh 13 ;; 14 stop) 15 $CATALINA_HOME/bin/shutdown.sh 16 ;; 17 restart) 18 $CATALINA_HOME/bin/shutdown.sh 19 sleep 5 20 $CATALINA_HOME/bin/startup.sh 21 ;; 22 *) 23 echo "USAGE: $0 {start|stop|restart}" 24 exit 1 25 esac
[[email protected] www.fox.com]# cat www.tomcat #!/bin/bash #chkconfig: 2345 96 14 #www.fox.com export JAVA_HOME=/usr/local/jdk export JAVA_HOME CATALINA_HOME export CATALINA_HOME=/usr/local/tomcat export CATALINA_BASE="/usr/local/tomcat/www.fox.com" export JAVA_OPTS=‘-Xms64m -Xmx128m‘ case "$1" in start) $CATALINA_HOME/bin/startup.sh ;; stop) $CATALINA_HOME/bin/shutdown.sh ;; restart) $CATALINA_HOME/bin/shutdown.sh sleep 5 $CATALINA_HOME/bin/startup.sh ;; *) echo "USAGE: $0 {start|stop|restart}" exit 1 esac
1 [[email protected] e-mail.fox.com]# cat mail.tomcat 2 #!/bin/bash 3 #chkconfig: 2345 96 14 4 #e-mail.fox.com 5 export JAVA_HOME=/usr/local/jdk 6 export JAVA_HOME CATALINA_HOME 7 export CATALINA_HOME=/usr/local/tomcat 8 export CATALINA_BASE="/usr/local/tomcat/e-mail.fox.com" 9 export JAVA_OPTS=‘-Xms64m -Xmx128m‘ 10 case "$1" in 11 start) 12 $CATALINA_HOME/bin/startup.sh 13 ;; 14 stop) 15 $CATALINA_HOME/bin/shutdown.sh 16 ;; 17 restart) 18 $CATALINA_HOME/bin/shutdown.sh 19 sleep 5 20 $CATALINA_HOME/bin/startup.sh 21 ;; 22 *) 23 echo "USAGE: $0 {start|stop|restart}" 24 exit 1 25 esac
1 [[email protected] ~]# chmod +x /usr/local/tomcat/bbs.fox.com/bbs.tomcat 2 [[email protected] ~]# chmod +x /usr/local/tomcat/www.fox.com/www.tomcat 3 [[email protected]omcat-node01 ~]# chmod +x /usr/local/tomcat/e-mail.fox.com/mail.tomcat
创建实例站点目录:
1 [[email protected] ~]# mkdir -p /usr/local/Application/{bbs.fox.com,www.fox.com,e-mail.fox.com}
启动脚本:
[[email protected] e-mail.fox.com]# ./mail.tomcat start Using CATALINA_BASE: /usr/local/tomcat/e-mail.fox.com Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/e-mail.fox.com/temp Using JRE_HOME: /usr/local/jdk Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar Tomcat started. [[email protected]-tomcat-node01 bbs.fox.com]# ./bbs.tomcat start Using CATALINA_BASE: /usr/local/tomcat/bbs.fox.com Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/bbs.fox.com/temp Using JRE_HOME: /usr/local/jdk Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar Tomcat started. [[email protected]-tomcat-node01 www.fox.com]# ./www.tomcat start Using CATALINA_BASE: /usr/local/tomcat/www.fox.com Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/www.fox.com/temp Using JRE_HOME: /usr/local/jdk Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar Tomcat started. [[email protected]-tomcat-node01 www.fox.com]# ss -nutpl |egrep "8081|8082|8083|8091|8092|8093" tcp LISTEN 0 100 :::8081 :::* users:(("java",pid=1016,fd=53)) tcp LISTEN 0 100 :::8082 :::* users:(("java",pid=1327,fd=53)) tcp LISTEN 0 100 :::8083 :::* users:(("java",pid=1264,fd=53)) tcp LISTEN 0 1 ::ffff:127.0.0.1:8091 :::* users:(("java",pid=1016,fd=65)) tcp LISTEN 0 1 ::ffff:127.0.0.1:8092 :::* users:(("java",pid=1327,fd=64)) tcp LISTEN 0 1 ::ffff:127.0.0.1:8093 :::* users:(("java",pid=1264,fd=65)) [[email protected]-tomcat-node01 www.fox.com]#
浏览器访问
bbs.fox.com实例web页面
www.fox.com实例web
e-mail.fox.com实例web
原文地址:https://www.cnblogs.com/xiaozhebao/p/12590263.html
时间: 2024-10-09 22:50:45