点击(此处)折叠或打开

  1. //创建用户和目录
  2. # useradd tomcat
  3. # mkdir /app
  4. # chown tomcat /app
  5. # su – tomcat

  6. //安装JDK
  7. $cd /app
  8. $wget jdk-8uXX-linux-x64.gz
  9. $tar zxvf jdk-8uXX-linux-x64.gz
  10. $ln -s jdk1.8.0_XX jdk

  11. //安装TOMCAT
  12. $wget apache-tomcat-8.0.XX.tar.gz
  13. $tar zxvf apache-tomcat-8.0.XX.tar.gz
  14. $ln -s apache-tomcat-8.0.XX tomcat

  15. //安装JSVC,APR参考其他资料

  16. //配置多实例
  17. $cd tomcat
  18. //删除没用的(不太礼貌…:
  19. $rm RUNNING.txt LICENSE NOTICE RELEASE-NOTES
  20. //创建实例模板目录
  21. $mkdir instance
  22. //移动后只共享CATALINA_HOME的bin,lib目录(其实实例的logs,work目录会在启动时自动创建)
  23. $mv conf logs temp webapps work instance
  24. $cp -r instance instance1
  25. $cp -r instance instance2
  26. //修改【Server,Connector】端口号,每个实例都不能一样。【Host appBase】web应用部署目录也可以根据需要修改。
  27. $vi instance1/conf/server.xml
  28. $vi instance2/conf/server.xml
  29. $su - root

  30. #cd /etc/init.d
  31. #cp /app/tomcat/bin/daemon.sh tomcat1
  32. #vi tomcat1
  33.     #!/bin/sh
  34.     #
  35.     #chkconfig: 345 80 21
  36.     #
  37.     # resolve links - $0 may be a softlink

  38.     TOMCAT_USER=tomcat
  39.     JAVA_HOME=/app/jdk
  40.     CATALINA_HOME=/app/tomcat
  41.     CATALINA_BASE=/app/tomcat/instance1
  42.     CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib -Dcom.sun.management.jmxremote" //这行根据需要来设置
  43.     ARG0="/app/tomcat"

  44. #cp tomcat1 tomcat2
  45. #vi tomcat2
  46.     CATALINA_BASE=/app/tomcat/instance2
  47. #chkconfig --add tomcat1
  48. #chkconfig --add tomcat2
  49. #chkconfig --list | grep tomcat
  50. #exit

  51. $service tomcat1 start
  52. $service tomcat2 start


12-11 13:58