Django uwsgi Nginx没有提供媒体文件

编辑:我已经取得了一些进展麻烦拍摄这个问题。 有关情况的更新,请阅读注释并在ServerFault上查看此帖: https ://serverfault.com/questions/690836/djangouwsginginx-not-serving-media-files-django-returns-404-status -code?noredirect = 1#comment851441_690836

我正在学习这个教程: http : //uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

一切进展顺利,直到我到达“基本nginxtesting”部分。 当我停下来,开始nginx,然后添加“media.png”到我的媒体文件夹,并去

192.168.***.***:8000/media/media.png 

它给了我一个404状态码。 请注意,这个状态码是由Django(DEBUG = True)给出的,所以它说:

 Page not found (404) Request Method: GET Request URL: http://192.168.***.***:8000/media/media.png Using the URLconf defined in CMS.urls, Django tried these URL patterns, in this order: 

这是mysite_nginx.conf:

 # mysite_nginx.conf # the upstream component nginx needs to connect to upstream django { # server unix:///path/to/your/mysite/mysite.sock; # for a file socket server 127.0.0.1:8001; # for a web port socket (we'll use this first) } # configuration of the server server { # the port your site will be served on listen 8000; # the domain name it will serve for server_name 192.168.***.***; # substitute your machine's IP address or FQDN charset utf-8; # max upload size client_max_body_size 75M; # adjust to taste # Django media location /media { alias /home/a/Documents/media; # your Django project's media files - amend as required } location /static { alias /home/a/Documents/CMS/CMSApp/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 /home/a/Documents/CMS/CMS/uwsgi_params; # the uwsgi_params file you installed } } 

任何想法,当我试图查看媒体文件时,得到一个404错误?

附加信息:当我去

 http://192.168.***.***:8001/media/media.png 

要么

 127.0.0.1:8001 

它说“这个网页不可用”。