【问题标题】:Static files are not loading after deployment on digitelocean在 digitalocean 上部署后未加载静态文件
【发布时间】:2021-03-24 14:03:36
【问题描述】:

我已经按照这个在 digitel ocean 上部署了我的 django 应用程序

博客:alocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-16-04

这是我在控制台获取静态文件时出现的错误网址

(索引):5913 GET http://67.205.160.21/static/js/dashkit.min.js net::ERR_ABORTED 403(禁止)(索引):5913 GET http://67.205.160.21/static/js/style.jsnet::ERR_ABORTED 403 (禁止)

除了静态文件,一切都很好,

settings.py

  STATIC_URL = '/static/'
  STATIC_ROOT = os.path.join(BASE_DIR, 'static')

运行 python3 manage.py collect static 后,它给出了这个

/home/podstatsclub/webapp/Podcast_stats/static

我已将其放入 default.config 文件中,看起来像这样

    Alias /static /home/podstatsclub/webapp/Podcast_stats/static
    <Directory /home/podstatsclub/webapp/Podcast_stats/static>
            <Files wsgi.py>
              Require all granted
            </Files>
    </Directory>

    <Directory /home/podstatsclub/webapp/Podcast_stats/podcast>
      <Files wsgi.py>
        Require all granted
      </Files>
    </Directory>

    WSGIDaemonProcess Podcast_stats python-home=/home/podstatsclub/webapp/Podcast_stats/env pytho>
    WSGIProcessGroup Podcast_stats
    WSGIScriptAlias / /home/podstatsclub/webapp/Podcast_stats/podcast/wsgi.py

【问题讨论】:

    标签: python django digital-ocean django-deployment


    【解决方案1】:

    在您的静态目录中,您意外地仅授予对 wsgi.py 的访问权限……这是一个复制粘贴错误。只需将“要求全部授予”留在那里。

    【讨论】:

    • emm 我写了这样的东西 要求所有授予
    • 我的意思是在 标签之后添加 Require all grant
    • 多么伟大的人,非常感谢你,你不知道的兄弟,你变得像天使一样,对你充满爱和美好的祝福
    猜你喜欢
    • 1970-01-01
    • 2017-03-01
    • 2017-12-06
    • 2020-09-17
    • 1970-01-01
    • 2021-07-31
    • 2019-12-21
    • 2015-08-22
    • 2014-06-18
    相关资源
    最近更新 更多