1.安装tomcat1.1下载32-bitWindowszip[apache-tomcat-7.0.4-windows-x86.zip]解压apache-tomcat-7.0.4-windows-x86.zipd:/apache/apache-tomcat-7.0.4|-bin|-conf|-lib|-logs|-temp|-webapps|-work[web应用的临时目录]|-...#定义%TOMCAT_HOME%=d:/apache/apache-tomcat-7.0.41.3启动tomcat%TOMCAT_HOME%/bin/startup.bat1.4访问tomcat关闭tomcat%TOMCAT_HOME%/bin/shutdown.bat2.部署web应用2.1方式一:编写context.xml文件#新建%TOMCAT_HOME%/conf/Catalina/localhost/my.xml#文件名my就是web应用的contextPath#my.xml内容如下?xmlversion=1.0encoding=utf-8?ContextdocBase=D:\workspace\eclipse_wksp\MyWebApp\WebContentreloadable=true/Context#docBase所指向的目录结构如下.../WebContent|-META-INF|-WEB-INF|-classes|-lib|-web.xml|-index.jsp|-...#启动tomcat#访问web应用方式二:将web应用直接复制到%TOMCAT_HOME%/webapps中#目录结构如下%TOMCAT_HOME%/webapps/myweb|-META-INF|-WEB-INF|-classes|-lib|-web.xml|-index.jsp|-...#目录名称myweb就是web应用的contextPath#启动tomcat#访问web应用方式三:.war部署#直接将MyWebApp.war复制到%TOMCAT_HOME%/webapps中#.war结构如下%TOMCAT_HOME%/webapps/MyWebApp.war|-META-INF|-WEB-INF|-classes|-lib|-web.xml|-index.jsp|-...#启动tomcat,tomcat将自动解压.war#其中MyWebApp.war的名称MyWebApp就是web应用的contextPath#访问web应用配置多个虚拟主机#修改%TOMCAT_HOME%/conf/server.xml#将Engine元素中的Host元素复制一份,直接粘贴到原来那个Host元素之后#将第二个Host元素的name属性改为localhost2,appBase属性改为webapps2#创建目录%TOMCAT_HOME%/conf/Catalina/localhost2#创建目录%TOMCAT_HOME%/webapps2#将web应用myapp复制到%TOMCAT_HOME%/webapps2#其中myapp目录结构如下%TOMCAT_HOME%/webapps2/myapp|-META-INF|-WEB-INF|-classes|-lib|-web.xml|_index.jsp|-...#编辑C:\Windows\System32\drivers\etc\hosts#在ubuntu中为/etc/hosts#添加下面一行内容127.0.0.1localhost2#启动tomcat#访问web应用配置多个Service#修改%TOMCAT_HOME%/conf/server.xml#将Service元素复制一份,直接粘贴到原来那个Service元素之后#按照下列步骤修改第二个Service元素:#将Service元素的name属性改为Catalina2#将第一个Connector元素的port属性由8080改为8081#将第二个Connector元素的port属性由8009改为8010#将Engine元素的name属性由Catalina改为Catalina2,与Service的name属性保持一致#将Host元素的appBase属性由webapps改为webapps2#创建目录%TOMCAT_HOME%/conf/Catalina2/localhost%TOMCAT_HOME%/webapps2#将%TOMCAT_HOME%/webapps/ROOT复制到%TOMCAT_HOME%/webapps2xcopywebapps\ROOTwebapps2\ROOT/E[windows]$cpwebapps\ROOTwebapps2\ROOT[linux]#启动tomcat#访问tomcat主页://localhost:8081/5.tomcat内存溢出处理办法#修改%TOMCAT_HOME%/bin/catalina.bat#-Xms初始堆大小#-Xmx最大堆大小#-XX:PermSize初始永久区大小#-XX:MaxPermSize最大永久区大小setJAVA_OPTS=-server-Xincgc-Xms1024m-Xmx1024m-XX:MaxPermSize=256m#具体有哪些参数可查看[java-X]或#://download.oracle.com/javase/6/docs/technotes/guides/javaws/developersguide/syntax.html#resources#参考文章#://使用JRebelhotupdate.class#修改%TOMCAT_HOME%/bin/catalina.batsetJAVA_OPTS=%JAVA_OPTS%-noverify-javaagent:D:/library/lib_share/jrebel.jar#上述设置可以动态更新WEB-INF/classes中的.class,#但对WEB-INF/lib中的.jar无效,如果要动态更新.jar,#需要创建WEB-INF/classes/rebel.xml,内容如下?xmlversion=1.0encoding=UTF-8?applicationxmlns:xsi====D:\workspace\eclipse_my\Test\WebContent\WEB-INF\classes//classpath/application#引:@echo%JAVA_OPTS%setJAVA_OPTS=-noverify-javaagent:E:/apache-tomcat-6.0.29/jrebel/jrebel.jar