配置:
- Windows Server 2019
- 从https://www.iis.net/downloads/microsoft/httpplatformhandler安装了httpPlatformServer x64
- 已为所有用户安装Python 3.12.1 32位C:\python312-32\
- 已安装FastAPI库,使用
- 创建了新的应用程序池(Pool-A),使用自定义帐户(User-A)作为身份,无托管代码,集成管道
- 已创建C:\python-logs\文件夹用于日志
- 创建了C:\python-app\,文件为main.py
- 设置文件夹中User-A的完全控制:python312-32,python-logs,python-app
- 添加应用程序到路由/python-app与Pool-A
C:\python-app\main.py:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def read_root():
return {"message": "Sample app"}
字符串
C:\python-app\web.config(基于https://learn.microsoft.com/en-us/visualstudio/python/configure-web-apps-for-iis-windows?view=vs-2022)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="PythonHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="c:\python312-32\python.exe"
arguments="c:\python-app\main.py --port %HTTP_PLATFORM_PORT%"
stdoutLogEnabled="true"
stdoutLogFile="c:\python-app\python.log"
startupTimeLimit="60"
processesPerApplication="16">
<environmentVariables>
<environmentVariable name="SERVER_PORT" value="%HTTP_PLATFORM_PORT%" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
型
我总是得到:
- HTTP错误500.19 -内部服务器错误
- 错误代码0x 80070003
- 无法读取配置文件
怎么了?
我没有使用FastCGI,因为项目没有维护。
2条答案
按热度按时间iszxjhcz1#
此错误是由于缺少权限或物理路径与虚拟目录的路径不匹配而导致的。例如,Web应用程序物理根路径下不存在Web.config。
请验证Web.config路径是否存在并且权限设置是否正确。请收集进程监视器日志以获取有关错误的详细信息。
更多信息,请参考此链接:HRESULT代码0x80070003。
b1zrtrql2#
我已经包括了下面的指令使用FastAPI(Python库)在IIS与HTTP平台的Java。
1.为所有用户安装Python 3.12 64位(installer)
1.安装Microsoft HTTP Platform SDK 1.2(installer)
1.以管理员身份安装Python包
pip install fastapi uvicorn
1.创建文件夹
C:\python-app
1.创建文件夹
C:\python-app\logs
1.创建
C:\python-app\main.py
字符串
1.创建“C:\python-app\web.config”
型
PythonAppPool
型
http:\\localhost\python
web.config
文件中将--log-level
更改为error