如何在IIS上部署django应用程序错误403.14

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

我在 IIS 上部署 Django 应用程序时遇到问题。 我的

wsgi.py

import os
from django.core.wsgi import get_wsgi_application

os.environ.setdefault(
    'DJANGO_SETTINGS_MODULE',
    'BETA.settings')


application = get_wsgi_application()

在我的

settings.py
我有

DEBUG = True
ALLOWED_HOSTS = [some ip]
WSGI_APPLICATION = 'BETA.wsgi.application'

我的

__init__.py
是空的

在根目录中的 web.config 看起来像:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <defaultDocument>
            <files>
                <clear />
                <add value="login.html" />
            </files>
        </defaultDocument> 
    <handlers>
      <add 
        name="Python FastCGI" 
        path="*" 
        verb="*" 
        modules="FastCgiModule" 
        scriptProcessor = 'C:\Program Files\Python310\python.exe"|"C:\Program Files\Python310\lib\site-packages\wfastcgi.py'
        resourceType="Unspecified"
       </configuration> requireAccess="Script"
        />
    </handlers>
  </system.webServer>

  <appSettings>
    <add key="WSGI_HANDLER" value="BETA.wsgi.application">
    <add key="PYTHONPATH" value="D:\Applications\HRtool\dev\wwwroot\BETA">

    <add key="DJANGO_SETTINGS_MODULE" value="BETA.settings">
  </appSettings>

静态 web.config 中的下一个是:

<?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.webServer>
        <handlers>
          <clear/>
          <add name="StaticFile" path="*" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
        </handlers>
      </system.webServer>
    </configuration>

但是当我在国际空间站上启动我的应用程序时,我遇到了另一个问题:

我正在尝试启用目录浏览,但没有帮助。在池中提前设置我有.Net 4.5。如何解决?

python django iis web-deployment wsgi
1个回答
0
投票

如果您恢复与 FastCGI 相关的所有更改并使用 HttpPlatformHandler 干净地启动,您将看到体验是多么流畅,

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" requireAccess="Script" />
        </handlers>
        <httpPlatform stdoutLogEnabled="true" stdoutLogFile=".\python.log" startupTimeLimit="20" processPath="C:\Users\<user name>\AppData\Local\Programs\Python\Python310\python.exe" arguments=".\mysite\manage.py runserver %HTTP_PLATFORM_PORT%">
        </httpPlatform>
    </system.webServer>
</configuration>

Python/Django 仍然负责处理包括静态文件在内的所有事务,而 IIS/HttpPlatformHandler 只是传递请求。

更多详细信息可以从我的博客文章找到。

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