首页 > 解决方案 > 无法将 django 应用程序部署到 azure web 应用程序

问题描述

我从未将 django 项目部署到 Web 应用程序。我通常只是为了好玩而使用 localhost 构建它们。但是,我现在有一个我正在尝试部署到 Azure Web 应用程序,但一直碰壁。Azure 中的部署都是成功的,但是当我访问应用程序域时,我仍然只能看到基本页面“嘿,Python 开发人员!”

我已经阅读了一些现有的文档,并确保包含 web.config 文件以及使用 wsgi.py 文件。此外,我更新了我的 settings.py 文件以包含适当的 ALLOWED_HOSTS。下面是我的 django 文件夹结构:

|.venv
|naviwebsite
   |accounts
   |naviwebsite
       |settings.py
       |wsgi.py
   |manage.py
|requirements.txt
|web.config

此外,以下是我的 web.config 文件:

<configuration>
  <appSettings>
    <add key="WSGI_HANDLER" value="naviwebsite.wsgi.application"/>
    <add key="PYTHONPATH" value="D:\home\site\wwwroot"/>
    <add key="WSGI_LOG" value="D:\home\LogFiles\wfastcgi.log"/>
  </appSettings>
  <system.webServer>
    <handlers>
      <add name="PythonHandler" path="handler.fcgi" verb="*" modules="FastCgiModule" scriptProcessor="D:\home\python377x64\python.exe|D:\home\python377x64\wfastcgi.py" resourceType="Unspecified" requireAccess="Script"/>
    </handlers>
    <rewrite>
      <rules>
        <rule name="Static Files" stopProcessing="true">
          <conditions>
            <add input="true" pattern="false" />
          </conditions>
        </rule>
        <rule name="Configure Python" stopProcessing="true">
          <match url="(.*)" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_URI}" pattern="^/static/.*" ignoreCase="true" negate="true" />
          </conditions>
          <action type="Rewrite" url="handler.fcgi/{R:1}" appendQueryString="true" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

构成我的 django 应用程序的视图和表单都位于帐户文件夹中。在将他们的 django 应用程序部署到 Azure Linux Web 应用程序时,是否有其他人遇到过类似的问题?任何帮助将不胜感激!

谢谢

标签: pythondjangoazureazure-web-app-service

解决方案


推荐阅读