我有一个django应用程序,其中hompage路由正确,但当我试图点击任何链接时,我会收到404错误。我看了看日志,发现:
*1 open() "/usr/share/nginx/html/pricing" failed (2: No such file or directory)
这告诉我nginx并没有查看我的项目文件夹,而是查看默认设置。我使用的是centos,所以我不得不手动设置可用的网站和启用的网站,我用这些来让主页工作。因此,没有默认的conf可以禁用。我不确定如何让nginx路由到我的路径而不是默认路径。我的nginx.conf文件如下:
user so_dev;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*; #added by me
}
我遵循了一个糟糕的教程,其中有一个拼写错误。如果你碰巧遵循了相同的类型,你应该在你的nginx站点可用文件中放入:
location /
而非
location = /
https://www.shellvoide.com/hacks/installing-django-application-with-nginx-mysql-and-gunicorn-on-ubuntu-vps/