【发布时间】:2021-07-22 20:20:13
【问题描述】:
我正在使用 nginx 设置基本的 Django 站点。当我导航到文件的 url 时,我收到错误 404 Not Found nginx/1.18.0 (Ubuntu)
这是配置文件
upstream django {
server unix:///home/jo/testproject/testproject.sock;
}
# configuration of the server
server {
listen 80;
server_name _;
charset utf-8;
# max upload size
client_max_body_size 75M;
# Django media and static files
location /media/ {
alias /home/jo/testproject/media/;
}
location /static {
alias /home/jo/testproject/static;
}
# Send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /home/jo/testproject/uwsgi_params;
}
}
媒体文件夹位于 /home/jo/testproject/media 中,其中我有 media.gif,但 ip/media/media.gif 不起作用
当我在浏览器中写入 ip 时,我得到了
欢迎使用 Nginx! 如果您看到此页面,则 nginx Web 服务器已成功安装并正在运行。需要进一步配置。
有关在线文档和支持,请参阅 nginx.org。 nginx.com 上提供商业支持。
感谢您使用 nginx。
我认为其他所有设置都正确
【问题讨论】:
标签: django linux nginx http-status-code-404 media