我用NGINX和Gunicorn在一个有域的ubuntu服务器上设置了django-wagtail。我的CSS和JS文件在我的目录中的静态文件夹中得到了正确的服务,但是我不明白为什么Wagtail管理CSS/JS文件没有被服务。我假设这与Wagtail管理文件不在CSS/JS文件所在的静态文件夹中有关。 collectRan调试设置为False。在
googlechrome报告称,在管理CSS/JS上找不到404个文件
NGINX文件的一部分
server {
listen 443 default_server;
listen [::]:443 default_server;
root /home/projects/stemletics/stemletics/mysite/mysite;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name domain.com www.domain.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/projects/stemletics/stemletics/mysite/mysite;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/projects/stemletics/stemletics/mysite/mysite.sock;
}
相关部分基准.py
^{pr2}$生产.py
from .base import *
DEBUG = False
CSRF_COOKIE_SECURE = True
SESSION_COOKIE_SECURE = True
import os
SECRET_KEY = os.environ["DJANGO_SECRET_KEY_STEMLETICS"]
try:
from .local import *
except ImportError:
pass
静态文件夹路径
root@django-manaland:/# cd home/projects/stemletics/stemletics/mysite/mysite/static/
root@django-manaland:/home/projects/stemletics/stemletics/mysite/mysite/static# lsbrand css fonts img js scss
在nginx conf文件中,需要指向要从中提供静态资产的目录。乍一看,您所拥有的看起来是正确的(尽管我不能百分之百确定您是否需要在下面的示例中使用尾随斜杠;我总是保留在尾部斜杠中以防万一)
要获得该路径(从上面开始),ssh进入服务器,
cd
到Django的collectstatic
函数合并文件的目录,然后运行pwd
。它将返回一个路径,并确保以一个尾随斜杠结束(斜杠一直对我有效)相关问题 更多 >
编程相关推荐