点击(此处)折叠或打开
- //创建用户和目录
- # useradd tomcat
- # mkdir /app
- # chown tomcat /app
- # su – tomcat
- //安装JDK
- $cd /app
- $wget jdk-8uXX-linux-x64.gz
- $tar zxvf jdk-8uXX-linux-x64.gz
- $ln -s jdk1.8.0_XX jdk
- //安装TOMCAT
- $wget apache-tomcat-8.0.XX.tar.gz
- $tar zxvf apache-tomcat-8.0.XX.tar.gz
- $ln -s apache-tomcat-8.0.XX tomcat
- //安装JSVC,APR参考其他资料
- //配置多实例
- $cd tomcat
- //删除没用的(不太礼貌…:)
- $rm RUNNING.txt LICENSE NOTICE RELEASE-NOTES
- //创建实例模板目录
- $mkdir instance
- //移动后只共享CATALINA_HOME的bin,lib目录(其实实例的logs,work目录会在启动时自动创建)
- $mv conf logs temp webapps work instance
- $cp -r instance instance1
- $cp -r instance instance2
- //修改【Server,Connector】端口号,每个实例都不能一样。【Host appBase】web应用部署目录也可以根据需要修改。
- $vi instance1/conf/server.xml
- $vi instance2/conf/server.xml
- $su - root
- #cd /etc/init.d
- #cp /app/tomcat/bin/daemon.sh tomcat1
- #vi tomcat1
- #!/bin/sh
- #
- #chkconfig: 345 80 21
- #
- # resolve links - $0 may be a softlink
- TOMCAT_USER=tomcat
- JAVA_HOME=/app/jdk
- CATALINA_HOME=/app/tomcat
- CATALINA_BASE=/app/tomcat/instance1
- CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib -Dcom.sun.management.jmxremote" //这行根据需要来设置
- ARG0="/app/tomcat"
- #cp tomcat1 tomcat2
- #vi tomcat2
- CATALINA_BASE=/app/tomcat/instance2
- #chkconfig --add tomcat1
- #chkconfig --add tomcat2
- #chkconfig --list | grep tomcat
- #exit
- $service tomcat1 start
- $service tomcat2 start