gpt4 book ai didi

IIS 上的 django,进程意外退出

转载 作者:行者123 更新时间:2023-12-01 19:11:19 32 4
gpt4 key购买 nike

我已阅读了有关此主题的所有文章,但我仍然无法在 IIS 上运行 django 项目。错误消息为 500 Internal Server Error, c:\program files (x86)\python 3.5\python.exe - FastCGI 进程意外退出。

错误 500 的跟踪规则提供以下内容:

Error 
-FASTCGI_UNEXPECTED_EXIT


Warning
-SET_RESPONSE_ERROR_DESCRIPTION


ErrorDescription
c:\program files (x86)\python 3.5\python.exe - The FastCGI process exited unexpectedly


Warning
-MODULE_SET_RESPONSE_ERROR_STATUS


ModuleName
FastCgiModule

Notification
EXECUTE_REQUEST_HANDLER

HttpStatus
500

HttpReason
Internal Server Error

HttpSubStatus
0

ErrorCode
The system cannot find the file specified.
(0x2)

环境:

  • Windows Server 2012 R2
  • IIS 8.5(启用 CGI)
  • wfastcgi已安装并启用(命令“c:\program files (x86)\python 3.5\python.exe|c:\program files (x86)\python 3.5\lib\site-packages\wfastcgi.py”打开python shell - 这是对的吗?)

c:\inetpub\wwwroot\testapp 下的 web.config:

<configuration>
<system.webServer>
<handlers>
<add name="Python FastCGI" path="*" verb="*" modules="FastCgiModule" scriptProcessor="c:\program files (x86)\python 3.5\python.exe|c:\program files (x86)\python 3.5\Lib\site-packages\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" />
</handlers>
<tracing>
<traceFailedRequests>
<add path="*">
<traceAreas>
<add provider="ASP" verbosity="Verbose" />
<add provider="ISAPI Extension" verbosity="Verbose" />
<add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI,WebSocket" verbosity="Verbose" />
</traceAreas>
<failureDefinitions statusCodes="500" />
</add>
</traceFailedRequests>
</tracing>
</system.webServer>

<appSettings>
<!-- Required settings -->
<add key="WSGI_HANDLER" value="django.core.wsgi.get_wsgi_application()" />
<add key="PYTHONPATH" value="c:\inetpub\wwwroot\testapp" />

<!-- Optional settings -->
<add key="WSGI_LOG" value="C:\inetpub\logs\testapp.log" />
<add key="WSGI_RESTART_FILE_REGEX" value=".*((\.py)|(\.config))$" />
<add key="APPINSIGHTS_INSTRUMENTATIONKEY" value="__instrumentation_key__" />
<add key="DJANGO_SETTINGS_MODULE" value="testapp.settings" />
</appSettings>
</configuration>

感谢您的帮助。

最佳答案

我花了很多时间来解决这个问题,终于成功了。我将分享一些我尝试过的技巧。

环境

  • Windows Server 2012 R2
  • IIS 8.5(启用 CGI)
  • python 3.6.6
  • wfastcgi 3.0.0

1。文件夹权限

自留言FASTCGI_UNEXPECTED_EXIT显示,IIS 有权访问文件夹“项目文件夹”和“virtualenv 文件夹”

对于那些只收到 500 错误但没有消息的用户,请尝试将文件夹权限授予 IIS AppPool\<myapppoolname>

(引用:https://support.pkware.com/display/SMAR/KB+-+Granting+folder+permissions+to+IIS+application+pools)

如果您将应用程序池置于默认应用程序池下,请授予 IUSR 访问权限和IIS_IUSRS .

2。正确安装Python

引用:https://github.com/microsoft/PTVS/issues/5450

我曾经在用户文件夹下安装 python,而不是 C:\Python36 。所以我删除并使用从https://python.org/downloads下载的可执行安装程序重新安装

一些配置:

  1. 将 Python 添加到路径
  2. 为所有用户安装
  3. 位置 C:\Python36

请注意,我使用的是虚拟环境。但我知道很多教程都没有,而且它们似乎运行良好,所以请随意使用或不使用。

关于IIS 上的 django,进程意外退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36709620/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com