首页 > 解决方案 > 将 webapps 位置从 Tomcat 9 安装目录移动到另一个路径

问题描述

我按照https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-9-on-debian-10的教程安装了tomcat 9, 因此得到了安装路径/opt/tomcat

然后我决定将webapps文件夹移动到文件系统上的另一个路径。我的尝试是以这种方式将路径与文件中appBase主机配置中的变量相关联conf/server.xml

  <Host name="localhost"
    <!-- appBase="webapps" -->
        appBase="/opt/tomcat/webapps"
        unpackWARs="true" autoDeploy="true">

    <!-- SingleSignOn valve, share authentication between web applications
         Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
    -->

    <!-- Access log processes all example.
         Documentation at: /docs/config/valve.html
         Note: The pattern used is equivalent to using pattern="common" -->
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           prefix="localhost_access_log" suffix=".txt"
           pattern="%h %l %u %t &quot;%r&quot; %s %b" />

  </Host>

这不起作用,因此appBase变量无法获得绝对路径的值。如何将webapps文件夹移动到另一个位置,例如用户目录?

标签: tomcat

解决方案


请在 server.xml 文件中使用以下标记。

<Host name="localhost" appBase="/opt/tomcat/webapps" unpackWARs="true" autoDeploy="true">

推荐阅读