gpt4 book ai didi

python - 如何在 nginx 上提供 Django 静态文件

转载 作者:太空宇宙 更新时间:2023-11-04 10:47:08 24 4
gpt4 key购买 nike

我正在尝试使用 uWSGI 配置 Nginx 来为 Django 应用程序提供服务,但是管理面板的布局完全扭曲了......

这是我的 Nginx 配置:

upstream django {
server 127.0.0.1:8000;
}

server {
# the port your site will be served on
listen 4321;
# the domain name it will serve for
server_name localhost;
charset utf-8;
access_log /var/log/nginx/local-access.log;
error_log /var/log/nginx/local-error.log;

client_max_body_size 75M;

location /static/admin {

alias /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/;
}

location / {
uwsgi_pass django;
include /etc/nginx/uwsgi_params;
}

这是 Nginx 错误:2013/05/13 18:13:26 [error] 12491#0: *255 open() "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/ddsmoothmenu.js”失败(2:没有那个文件或目录)

访问日志:

[pid: 6848|app: 0|req: 8/13] 127.0.0.1 () {42 vars in 773 bytes} [Tue May 14 12:59:30 2013] GET /admin/ => generated 1960 bytes in 995 msecs (HTTP/1.1 200) 7 headers in 438 bytes (1 switches on core 0)
[pid: 6847|app: 0|req: 3/14] 127.0.0.1 () {44 vars in 858 bytes} [Tue May 14 12:59:32 2013] GET /admin/brightCouponsApp/static/admin/css/login.css => generated 0 bytes in 28 msecs (HTTP/1.1 500) 1 headers in 78 bytes (1 switches on core 0)

属于我的 Django 应用程序的静态文件工作正常,但 Django 管理布局不是有人可以帮助我...

最佳答案

查看 collectstatic命令而不是从您的站点包目录提供文件。管理命令基本上会将所有应用程序中的静态文件复制到 STATIC_ROOT 中。

关于python - 如何在 nginx 上提供 Django 静态文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16537566/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com