Mac Nginx。无法更改默认页面

Mac Nginx. Can't change the default page

很遗憾,我的 nginx 默认页面设置无法正常工作。我已经删除了 /var/www/ 中所有预装的 html 文件,但它仍然会加载默认文件..(还清除了浏览器缓存)

我当前的文件:

nginx.conf

    worker_processes  1;

error_log  /usr/local/etc/nginx/logs/error.log debug;

events {
    worker_connections  1024;
}

http {
include             mime.types;
default_type        application/octet-stream;

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  /usr/local/etc/nginx/logs/access.log  main;

sendfile            on;

keepalive_timeout   65;

index index.html index.php;

include /usr/local/etc/nginx/sites-enabled/*; 
}

sites-available/default

    server {
listen       80;
server_name  localhost;
root       /var/www/;

access_log  /usr/local/etc/nginx/logs/default.access.log  main;

location / {
    include   /usr/local/etc/nginx/conf.d/php-fpm;
}

error_page  404     /404.html;
error_page  403     /403.html;
}

sites-enabled 包含 sites-available 中文件的别名。

希望我没有遗漏任何东西!

在此先感谢您! :)

好的...让我们试试这个:

usr/local/etc/nginx/sites-available/default中,用

替换整个location /
location / {
  try_files $uri $uri/ /index.php$is_args$args;
}

这告诉 nginx 首先查找命名文件,然后是具有名称的目录,最后将它传递给 index.php。 (要了解更多关于 nginx 如何进行位置块匹配,我建议 this Digital Ocean article。)

然后,在/usr/local/etc/nginx/conf.d/php-fpm中删除try_files $uri = 404;行。

我很确定这是导致 /var/www404 查找的行,因为 = 404 之间不应该有 space。此外,该部分中的 try_files 并没有做太多。

至于从哪里提取内容,'Clone my example virtual host' 步骤是将 index.html 复制到 /var/www