【发布时间】:2020-06-18 15:58:22
【问题描述】:
我有一个 django 应用程序,主页路由正确,但是当我尝试单击任何链接时,我收到 404 错误。我查看了日志并看到:
*1 open() "/usr/share/nginx/html/pricing" failed (2: No such file or directory)
这告诉我 nginx 没有查看我的项目文件夹,而是查看了似乎是默认设置的内容。我使用的是 centos,所以我必须手动设置可用的站点和已启用的站点,这是我用来使主页正常工作的。因此,没有要禁用的默认配置。我不确定如何让 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
}
【问题讨论】:
标签: django nginx centos django-deployment