在IIS上部署Django的静态文件

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

我在 Stack Overflow 上读到了一些类似的问题,但仍然遇到这个问题。除了管理的 CSS 样式和所有 CSS 之外,Web Django 可以很好地部署在 IIS 上。

我尝试过的:

  1. 使用whitenoise -> 当我在中间件中编写whitenoise标签时出现错误。然后我就停止使用这种方式了
  2. 使用添加虚拟目录 更多信息 -> 我创建了虚拟环境 venv_>我的django>应用程序文件夹 老实说,我真的不知道虚拟目录(名为 static )应该在哪里,然后我尝试了
    1. 默认网站
    2. venv_
    3. 我的项目文件夹(使用collectstatic Django后我的静态文件夹) 我尝试使用物理路径(使用collectstatic Django后的静态文件夹) 还是不行

更多信息:

我使用了 findstatic 但没有得到另一个路径(在我的项目应用程序中收集静态路径) 它在我的 venv_ 包中?

django iis deployment static
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.