django - nginx 停止使用 WSL 为 django 应用程序提供静态文件夹
问题描述
我正在使用 WSL 运行 nginx 在“d”分区上为 django 应用程序提供服务,昨天它工作得很好,今天停止正常工作。这是我的 conf 文件:
upstream django {
# server unix:///path/to/your/mysite/mysite.sock; # for a file socket
server xxx.xxx.x.xxx:8000;
}
# configuration of the server
server {
# the port your site will be served on
listen 8000;
# the domain name it will serve for
server_name xxx.xxx.x.xxx; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django static
location /static {
alias /mnt/d/backend/static; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /etc/nginx/uwsgi_params; # the uwsgi_params file you installed
}
}
服务器和域名与设置中允许的主机相同。
STATIC_ROOT = os.path.join(BASE_DIR,"static")]
我不确定我是否指的是静态文件的正确路径。由于它们位于不同的位置,我对同时使用虚拟环境和 wsl 有点困惑。
(venv) root@DESKTOP-XXXXXX:/mnt/d/backend
问题是服务器不加载静态文件。
解决方案
推荐阅读
- python - 在 Unix 系统上使用 Python Ctypes 函数调用分段错误
- javascript - 如何添加 ScrollMagic 做出反应?
- php - 将 MySQL 更新到 8.0 后 Laravel 抛出 QueryException
- java - 使用递归将数组按特定条件分成 2 组
- android - CoordinatorLayout 与 RecyclerView 滚动错误
- algorithm - 与 log(n) 行为混淆
- c# - 访问控制器时发生堆栈溢出
- javascript - 如何从 document.querySelectorAll() 正确循环遍历 NodeList?
- sorting - 猫鼬; 排序,使某个记录首先出现
- python - 几分钟后 SQLAlchemy 会话不断下降