tomcat部署项目

工作目录介绍

tomcat的根目录:TOMCAT_HOME=/var/tomcat

部署的文件: /data/app.war

部署的项目首页:index.html

启动tomcat脚本:${TOMCAT_HOME}/bin/startup.sh

停止tomcat脚本:${TOMCAT_HOME}/bin/shutdown.sh

方式一:将.war文件复制到webapps目录。

  1. 拷贝文件到webapps目录

    1
    cp /data/app.war ${TOMCAT_HOME}/webapps
  2. 启动tomcat

  3. 浏览器访问http://localhost:8080/app/index.html

方式二:将解压后的目录复制到webapps目录

  1. 解压web.war

    1
    tar -zxvf /data/app.war /data/app
  2. 拷贝文件到webapps目录

    1
    cp /data/app ${TOMCAT_HOME}/webapps/app
  3. 启动tomcat

  4. 浏览器访问http://localhost:8080/app/index.html

方式三:使用自定义项目目录

  1. 解压web.war

    1
    tar -zxvf /data/app.war /data/app
  2. 修改server.xml文件,在HOST标签内部添加如下文本

    1
    <Context path="/app" docBase="/data/app" debug="0" privileged="true" />
  3. 启动tomcat

  4. 浏览器访问http://localhost:8080/app/index.html