【问题标题】:Static files in Nginx, Gunicorn in DjangoNginx 中的静态文件,Django 中的 Gunicorn
【发布时间】:2013-08-12 17:15:05
【问题描述】:

我已经尝试了我找到的所有配置,并且没有加载静态文件,所以我不知道出了什么问题。我使用 Pycharm 创建应用程序。

有人可以帮我解决这个问题吗?

这里是配置。

settings.py

MEDIA_ROOT = ''
MEDIA_URL = '/Users/gcarranza/PycharmProjects/clouddemyTest/'

STATIC_ROOT = ''
STATIC_URL = '/Users/gcarranza/PycharmProjects/clouddemyTest/static/'

STATICFILES_DIRS = (
'/Users/gcarranza/PycharmProjects/clouddemyTest/static',)

nginx 配置:

server {
    listen       80;
    server_name  localhost;

    location /static/ {
        autoindex on;
        alias   /Users/gcarranza/PycharmProjects/clouddemyTest/static/; 
    } 
    location / {
        proxy_pass http://127.0.0.1:8000;
    }
}

独角兽:

gunicorn_django -b localhost:8000

【问题讨论】:

    标签: django nginx gunicorn django-staticfiles


    【解决方案1】:

    你得到了 root 和 url。应该是:

    STATIC_ROOT = '/Users/gcarranza/PycharmProjects/clouddemyTest/static/'
    STATIC_URL = '/static/'
    

    媒体也是如此

    【讨论】:

    • 这解决了我的问题,谢谢。
    猜你喜欢
    • 2012-11-20
    • 1970-01-01
    • 2015-11-30
    • 2013-06-27
    • 2017-05-31
    • 2021-08-08
    • 2015-03-30
    • 2021-05-12
    • 2021-07-18
    相关资源
    最近更新 更多