1
我跟着this tutorial爲了讓我的Django應用程序部署在DigitalWater VPS與uWSGI和Nginx。靜態文件運行良好,但Django應用程序本身沒有。 (404未找到 - nginx的/ 1.9.6)Nginx響應404 Django應用程序,但靜態文件工作
# Where to look for content (static and media)
root /srv/www/$host/;
# Allow gzip compression
gzip_types text/css application/json application/x-javascript;
gzip_comp_level 6;
gzip_proxied any;
# Look for files with .gz to serve pre-compressed data
gzip_static on;
server {
listen 80;
# nginx docs recommend try_files over "if"
location / {
# Try to serve existing files first
try_files $uri @proxy =404;
}
location @proxy {
# Pass other requests to uWSGI
uwsgi_pass unix://srv/apps/_/server.sock;
include uwsgi_params;
}
}
確保套接字'/ srv/apps/_/server.sock'存在。如果沒有,請檢查您的uWSGI配置。 – GwynBleidD
你的'try_files'的語法是錯誤的。 '@ proxy'或'= 404'應該是最後一個元素 - 你不能同時擁有這兩個元素。請參閱[本文檔](http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files) –
存在'/ srv/apps/_/server.sock'。 –