补充:请注意,以下这个配置并不适合用在生产环境,因为它启动的是开发环境的简易服务器,要用在生产环境还是需要配合HttpPlatformHandler + waitress (因为Gunicorn 和 uwsgi 不支持windows)
arguments="manage.py runserver %HTTP_PLATFORM_PORT%"
微软官方提示建议使用 HttpPlatform 配置应用,因为他们不再维护 WFastCGI 项目 了。
首先下载并安装HttpPlatformHandler https://www.iis.net/downloads/microsoft/httpplatformhandler
然后直接把以下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="D:\http\asp\www_mysite\venv\Scripts\python.exe" arguments="manage.py runserver %HTTP_PLATFORM_PORT%" requestTimeout="00:04:00" startupTimeLimit="120" startupRetryCount="3" stdoutLogEnabled="true">
<environmentVariables>
<environmentVariable name="PYTHONPATH" value="D:\http\asp\www_mysite\mysite"/>
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
就这么简单,不需要wfastcgi那些enable什么的设置了
具体参考:
对于Django来说,可以直接参考https://azureossd.github.io/2017/09/01/django-app-with-httpplatformhandler-in-azure-app-services-windows/
更通用则参考官方指引:
《为 Python Web 应用配置 IIS》:
《HttpPlatformHandler 配置参考》: