python.exe-FastCGI进程意外退出 [英] python.exe - The FastCGI process exited unexpectedly

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

问题描述

我已经在这里和IIS论坛上阅读了有关此问题的所有文章,也将其发布到了Google的第二页上……仍然无法正常工作.

我想在Windows Server 2016上的IIS中运行Flask/Python应用,但我一直收到此错误:

  HTTP错误500.0-内部服务器错误C:\ Program Files \ Python38 \ python.exe-FastCGI进程意外退出详细的错误信息:模块FastCgiModule通知ExecuteRequestHandler处理程序FastCGI-Python错误代码0x00000002 

我设法使其在我的机器上运行(Windows 10),但在服务器上不起作用.

环境

  • Windows Server 2016
  • IIS 10
  • Python 3.8
  • wfastcgi 3.0.0
  • 烧瓶1.1.1

我尝试了不同版本的Python(3.6、3.7、3.8).在我的Windows 10上,它正在运行Python 3.7,并且运行正常.我无法使用Python 3.4.2,因为它在

6)打开iis.

右键单击服务器名称,然后选择添加站点.

输入站点名称的物理路径和站点绑定.

添加站点后,选择站点名称,然后从中间窗格中选择处理程序映射功能.

点击添加模块映射"

可执行路径值:

C:\ Python37-32 \ python.exe | C:\ Python37-32 \ Lib \ site-packages \ wfastcgi.py

点击请求限制".确保未选中仅在请求映射到时才调用处理程序:"复选框:

在此处单击是":

7)现在返回并选择应用程序设置功能.<​​/p>

在操作窗格中单击添加.

设置PYTHONPATH变量(这是您的站点文件夹路径):

然后是WSGI_HANDLER(我的Flask应用程序名为app.py,因此值为app.app -如果您的名称为site.py,则它将为site.app或类似名称):

8)单击确定"并浏览到您的站点.

注意:不要忘记为站点文件夹和python文件夹分配iis_iusrs和iusr权限.

I have read all posts about this issue, here and on IIS forum, got it to the second page on Google too... and still can't get it to work.

I want to run Flask/Python app in IIS on Windows server 2016, but I keep getting this error:

HTTP Error 500.0 - Internal Server Error
C:\Program Files\Python38\python.exe - The FastCGI process exited unexpectedly

Detailed Error Information:
Module     FastCgiModule
Notification       ExecuteRequestHandler
Handler    FastCGI-Python
Error Code     0x00000002

I managed to get it work on my machine (Windows 10), but on server nope.

Environment

  • Windows Server 2016
  • IIS 10
  • Python 3.8
  • wfastcgi 3.0.0
  • Flask 1.1.1

I tried different versions of Python (3.6, 3.7, 3.8). On my Windows 10 it's running Python 3.7 and it's working fine. I can't use Python 3.4.2, as it was suggested in one of the posts, because Flask runs on 3.5 and higher and apparently wfastcgi works fine with Python 3.7 on my machine.

I granted full permissions to my application pool and to IIS_IUSRS on my web app folder and Python folder.

I have installed Microsoft C++ Build Tools too.

And the configuration of IIS has been shared from my machine to server through "Shared Configuration", so everything is the same. I just adapted some paths in config file.

I tried also running web app on Flask WSGI server for development and it worked fine.

Does anyone has a clue what more I can do? Any advice would be nice.

Thanks :)

EDIT: I've added a warning message from event viewer.

+ System 
- EventData 
  Path C:\inetpub\history\CFGHISTORY_0000000051 
   12000780 
--------------------------------------------------------------------------------
Binary data:
In Words
0000: 80070012    
In Bytes
0000: 12 00 07 80      

EDIT: Added web.config file

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <remove name="FastCGI-Python" />
            <add name="FastCGI-Python" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\Program Files\Python38\python.exe|C:\Program Files\Python38\lib\site-packages\wfastcgi-3.0.0-py3.8.egg\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" />
        </handlers>
        <security>
            <authentication>
                <windowsAuthentication enabled="true" />
                <anonymousAuthentication enabled="false" />
            </authentication>
        </security>
    </system.webServer>
    <appSettings>
       <add key="PYTHONPATH" value="C:\inetpub\wwwroot\flaskr" />
       <add key="WSGI_HANDLER" value="__init__.app" />
       <add key="WSGI_LOG" value="C:\inetpub\wwwroot\flaskr\wfastcgi.log" />
    </appSettings>
</configuration>

解决方案

You could follow the below steps to configure python flask application in iis:

1)First, you need to install the python,wfastcgi, and flask at your server.

You can download the python from below link:

https://www.python.org/downloads/

Note: if possible please use python version above 3.6.

2)after installing python install the wfastcgi. run the command prompt as administrator and run below command:

pip install wfastcgi

wfastcgi-enable

3)below is my flask example:

from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
    return "Hello from FastCGI via IIS!"
if __name__ == "__main__":
    app.run()

4)after creating an application to run it use below command:

python app.py

5)enable the cgi feature of iis:

6)open iis.

right-click on the server name and select add site.

enter the site name physical path and the site binding.

after adding site select the site name and select the handler mapping feature from the middle pane.

Click "Add Module Mapping"

executable path value:

C:\Python37-32\python.exe|C:\Python37-32\Lib\site-packages\wfastcgi.py

Click "Request Restrictions". Make sure "Invoke handler only if the request is mapped to:" checkbox is unchecked:

Click "Yes" here:

7)now go back and select the application setting feature.

click add from the action pane.

Set the PYTHONPATH variable(which is your site folder path):

And the WSGI_HANDLER (my Flask app is named app.py so the value is app.app — if yours is named site.py it would be site.app or similar):

8)Click OK and browse to your site.

Note: Do not forget to assign the iis_iusrs and iusr permission to the site folder and the python folder.

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

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