【App Service for Windows】为 App Service 配置自定义 Tomcat 环境

简介: 【App Service for Windows】为 App Service 配置自定义 Tomcat 环境

问题描述

当在App Service for Windows环境中所列出的Tomcat Version 没有所需要的情况下,如何实现自定义Tomcat 环境呢?

 

问题解答

第一步: 从官网下载要使用的 tomcat 版本,解压到本地目录

 

第二步:修改 conf/server.xml 配置文件

  • port 改成 -1

  • Http-connect port 改成 ${port.http}

  • 注释 AJP 和 HTTPS 连接

  • host 改变为 127.0.0.1,并将 appBase 定位到 wwwroot 下的 webapps 目录:
    若 appbase 定位的是 ../../webapps,那项目文件应该放在 site-->wwwroot-->webapps-->ROOT 目录下。
    若 appbase 定位的是 webapps,那项目文件应该放在 /site/wwwroot/bin/apache-tomcat-<version>/webapps/ROOT

 

第三步:修改 conf/catalina.properties 文件,末尾加入 java.net.preferIPv4Stack=true

 

 

第四步:上传 Tomcat/java 目录到 site/wwwroot/bin

 

第五步:在 site/wwwroot 目录下上传 web.config 内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
    </handlers>
    <httpPlatform processPath="%HOME%\site\wwwroot\bin\tomcat\bin\startup.bat"  arguments="">
      <environmentVariables>
        <environmentVariable name="CATALINA_OPTS" value="-Dport.http=%HTTP_PLATFORM_PORT%" />
        <environmentVariable name="CATALINA_HOME" value="%HOME%\site\wwwroot\bin\tomcat" />
        <environmentVariable name="JRE_HOME" value="C:\home\site\wwwroot\bin\java\jdkx.x.x_xx\jrex" /> 
        <environmentVariable name="JAVA_OPTS" value="-Djava.net.preferIPv4Stack=true" />
      </environmentVariables>
    </httpPlatform>
  </system.webServer>
</configuration>

 

重启网站。以检查配置是否生效。

相关文章
|
5天前
【Azure Logic App】使用Event Hub 连接器配置 Active Directory OAuth 认证无法成功连接到中国区Event Hub的解决之法
An exception occurred while retrieving properties for Event Hub: logicapp. Error Message: 'ClientSecretCredential authentication failed: AADSTS90002: Tenant 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' not found. Check to make sure you have the correct tenant ID and are signing into the correct cloud. Che
|
11天前
|
安全
【Azure App Service】App service无法使用的情况分析
App Service集成子网后,如果子网网段中的剩余IP地址非常少的情况下,会在App Service实例升级时( 先加入新实例,然后在移除老实例 )。新加入的实例不能被分配到正确的内网IP地址,无法成功的访问内网资源。 解决方法就是为App Service增加子网地址, 最少需要/26 子网网段地址。
|
14天前
|
应用服务中间件 Linux iOS开发
使用 setenv 配置文件管理 Tomcat 的自定义环境变量
【8月更文挑战第29天】通过在Tomcat安装目录的`bin`文件夹下创建`setenv.sh`或`setenv.bat`文件,可以轻松管理Tomcat的自定义环境变量。针对Linux/macOS系统,需编辑`setenv.sh`文件,如`export MY_CUSTOM_VAR=&quot;my custom value&quot;`;而在Windows系统中,则编辑`setenv.bat`,如`set MY_CUSTOM_VAR=my custom value`。
|
20天前
|
开发框架 .NET Windows
【App Service】在App Service中配置Virtual applications and directories,访问目录中的静态文件报错404
【App Service】在App Service中配置Virtual applications and directories,访问目录中的静态文件报错404
|
20天前
|
C++
【Azure Logic App】使用Event Hub 连接器配置 Active Directory OAuth 认证无法成功连接到中国区Event Hub
【Azure Logic App】使用Event Hub 连接器配置 Active Directory OAuth 认证无法成功连接到中国区Event Hub
|
20天前
|
安全 网络安全 Windows
【Azure App Service】遇见az命令访问HTTPS App Service 时遇见SSL证书问题,暂时跳过证书检查的办法
【Azure App Service】遇见az命令访问HTTPS App Service 时遇见SSL证书问题,暂时跳过证书检查的办法
【Azure App Service】遇见az命令访问HTTPS App Service 时遇见SSL证书问题,暂时跳过证书检查的办法
|
20天前
|
安全 前端开发 网络安全
【Azure App Service】访问App Service应用报错 SSL: WRONG_VERSION_NUMBER
【Azure App Service】访问App Service应用报错 SSL: WRONG_VERSION_NUMBER
|
20天前
|
开发框架 JavaScript 前端开发
【App Service】解决 .NET Profiler 报告打开后无数据加载的问题
【App Service】解决 .NET Profiler 报告打开后无数据加载的问题
|
20天前
|
存储 Linux 网络安全
【Azure App Service】.NET代码实验App Service应用中获取TLS/SSL 证书 (App Service Linux/Linux Container)
【Azure App Service】.NET代码实验App Service应用中获取TLS/SSL 证书 (App Service Linux/Linux Container)