IIS上的django,进程意外退出

问题描述 投票:3回答:1

我已经阅读了有关该主题的每篇文章,但仍然无法在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外壳-这是对的吗?)

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>

感谢您的帮助。

django iis-8
1个回答
0
投票

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

环境

  • 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

如果将您置于默认的AppPool下,请授予对IUSRIIS_IUSRS的访问权限。

2。正确安装Python

参考:https://github.com/microsoft/PTVS/issues/5450

我曾经将python安装在用户文件夹下,而不是C:\Python36下。因此,我删除并重新安装了从https://python.org/downloads

下载的可执行安装程序

某些配置:

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

请注意,我正在使用虚拟环境。但是我知道很多教程都做不到,而且看来效果很好,所以请随时使用或不使用。

© www.soinside.com 2019 - 2024. All rights reserved.