IIS上的django,进程意外退出 [英] django on IIS, process exited unexpectedly

查看:166
本文介绍了IIS上的django,进程意外退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

 错误-FASTCGI_UNEXPECTED_EXIT警告-SET_RESPONSE_ERROR_DESCRIPTION错误说明c:\ program files(x86)\ python 3.5 \ python.exe-FastCGI进程意外退出警告-MODULE_SET_RESPONSE_ERROR_STATUS模块名FastCgi模块通知EXECUTE_REQUEST_HANDLERHttpStatus500HttpReason内部服务器错误HttpSubStatus0错误代码该系统找不到指定的文件.(0x2) 

环境:

  • Windows Server 2012 R2
  • IIS 8.5(已启用CGI)
  • 已安装并启用了wfastcgi(命令"c:\程序文件(x86)\ python 3.5 \ python.exe | c:\程序文件(x86)\ python 3.5 \ lib \ site-packages \ wfastcgi.py"打开了python shell-这对吗?)

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

 < configuration>< system.webServer><处理程序><添加名称="Python FastCGI" path ="*"动词="*" modules ="FastCgiModule" scriptProcessor ="c:\ program files(x86)\ python 3.5 \ python.exe | c:\ program files(x86)\ python 3.5 \ Lib \ site-packages \ wiftcgi.py"resourceType =" Unspecified"requireAccess =" Script"/></handlers><追踪>< traceFailedRequests><添加路径="*">< traceAreas>< add provider ="ASP" verbosity ="Verbose"/>< add provider ="ISAPI Extension" verbosity ="Verbose"/>< add provider ="WWW Server" areas =身份验证,安全性,过滤器,StaticFile,CGI,压缩,缓存,RequestNotifications,模块,FastCGI,WebSocket" verbosity ="Verbose"/></traceAreas>< failureDefinitions statusCodes ="500"/></add></traceFailedRequests></跟踪></system.webServer>< appSettings><!-必需的设置-><添加key ="WSGI_HANDLER" value ="django.core.wsgi.get_wsgi_application()"/><添加key ="PYTHONPATH" value ="c:\ inetpub \ wwwroot \ testapp"/><!-可选设置-><添加key ="WSGI_LOG" value ="C:\ inetpub \ logs \ testapp.log"/><添加密钥="WSGI_RESTART_FILE_REGEX" value =.*((\.py)|(\.config))$"/>< add key ="APPINSIGHTS_INSTRUMENTATIONKEY" value ="__ instrumentation_key__"/><添加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 )

如果将您置于默认的AppPool下,请授予对 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

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

I have read every article I could find on this topic but I'm still unable to run django project on IIS. The error message is 500 Internal Server Error, c:\program files (x86)\python 3.5\python.exe - The FastCGI process exited unexpectedly.

Tracing rule for error 500 provides the following:

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) 

environment:

  • Windows Server 2012 R2
  • IIS 8.5 (CGI enabled)
  • wfastcgi installed and enabled (command "c:\program files (x86)\python 3.5\python.exe|c:\program files (x86)\python 3.5\lib\site-packages\wfastcgi.py" opens a python shell - is this right?)

web.config under c:\inetpub\wwwroot\testapp:

<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>

thanks for any help.

解决方案

I've spent lot of time to solve this problem and finally made it. I'll share some tips that I've tried.

Environment

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

1. Folder permission

Since message FASTCGI_UNEXPECTED_EXIT showed up, IIS had permission to access folders 'project folder' and 'virtualenv folder'

For those who only got 500 Error but no message, try granting folder permissions to IIS AppPool\<myapppoolname>

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

If you're placing your under default AppPool, grant access to IUSR and IIS_IUSRS.

2. Install Python Properly

Reference: https://github.com/microsoft/PTVS/issues/5450

I used to install python under user folder instead of C:\Python36. So I removed and re-installed with executable installer downloaded from https://python.org/downloads

Some configurations:

  1. Add Python to Path
  2. Install for all users
  3. Location C:\Python36

Note that I am using virtual environment. But I know many tutorials don't and they seems working fine, so feel free to use or not.

这篇关于IIS上的django,进程意外退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆