我已经阅读了关于该主题的所有文章,但我仍然无法在 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)
- 蟒蛇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 https://support.pkware.com/display/SMAR/KB+-+Granting+folder+permissions+to+IIS+application+pools)
如果您将应用程序池置于默认应用程序池下,请授予访问权限IUSR
and IIS_IUSRS
.
2.正确安装Python
参考:https://github.com/microsoft/PTVS/issues/5450 https://github.com/microsoft/PTVS/issues/5450
我曾经在用户文件夹下安装 python 而不是C:\Python36
。所以我删除并使用从下载的可执行安装程序重新安装https://python.org/downloads https://python.org/downloads
一些配置:
- 将 Python 添加到路径
- 为所有用户安装
- 地点
C:\Python36
请注意,我使用的是虚拟环境。但我知道很多教程都没有,而且它们似乎工作得很好,所以请随意使用或不使用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)