首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >IIS winserver 2016 wfastcgi处理程序第791行上的django

IIS winserver 2016 wfastcgi处理程序第791行上的django
EN

Stack Overflow用户
提问于 2020-02-29 19:12:15
回答 1查看 2.2K关注 0票数 2

将python 3.8.1、django 3.0.3安装在windows server 2016上,并在wfastcgi和iam上安装了此错误,无法找到任何可以修复的错误。

让IIS AppPool\DefaultAppPool读取并使用python安装文件夹上的权限,但它仍然无法工作,处理程序无法读取它,但据我所知,配置似乎是正确的。希望你能帮我。谢谢你的问候。

C:\inetpub\wwwroot -> web.conf

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="Python FastCGI"
                path="*"
                verb="*"
                modules="FastCgiModule"
                scriptProcessor="c:\users\administrator\python38\python.exe|c:\users\administrator\python38\lib\site-packages\wfastcgi.py"
                resourceType="Unspecified"
                requireAccess="Script" />
        </handlers>
    </system.webServer>

    <appSettings>
        <!-- Required settings --> 
        <add key="WSGI_HANDLER" value="web.wsgi.application" />
        <add key="PYTHONPATH" value="C:\inetpub\wwwroot\AddressLizenzbuch" />

        <!-- Optional settings -->

        <add key="DJANGO_SETTINGS_MODULE" value="web.settings" />

    </appSettings>
</configuration>

C:\inetpub\wwwroot\AddressLizenzbuch\web\blog\static -> web.config

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <!-- Overrides the FastCGI handler to let IIS serve the static files -->
        <handlers>
            <clear/>
            <add name="StaticFile" path="*" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
        </handlers>
    </system.webServer>
</configuration>

manage.py

代码语言:javascript
复制
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'web.settings')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)


if __name__ == '__main__':
    main()

错误

代码语言:javascript
复制
Error occurred while reading WSGI handler:

Traceback (most recent call last):
  File "c:\users\administrator\python38\lib\site-packages\wfastcgi.py", line 791, in main
    env, handler = read_wsgi_handler(response.physical_path)
  File "c:\users\administrator\python38\lib\site-packages\wfastcgi.py", line 633, in read_wsgi_handler
    handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
  File "c:\users\administrator\python38\lib\site-packages\wfastcgi.py", line 603, in get_wsgi_handler
    handler = getattr(handler, name)
AttributeError: module 'web' has no attribute 'wsgi'


StdOut: 

StdErr:

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-05-23 00:02:37

这应该是一个简单的解决办法。Django项目的结构如下

C:/inetpub/wwwroot/AddressLizenzbuch/web/webweb.config

问题是额外的目录AddressLizenzbuch移除IT.

您的目录应该类似于C:/inetpub/wwwroot/web/web

问题是,wfastcgi.py正在寻找C:/inetpub/wwwroot/AddressLizenzbuch/web/wsgi.py,但这条路径显然不存在。在删除非必要目录AddressLizenzbuch之后,您的配置文件应该包括这一行。

代码语言:javascript
复制
<add key="PYTHONPATH" value="C:\inetpub\wwwroot\web" />

为了澄清这一点,您的wsgi.py文件应该位于C:\inetpub\wwwroot\web\web\wsgi.py

如果您还有其他问题,可以在网络项目 on GitHub上浏览这个项目

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60468696

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档