Ubuntu 16.04 中出现 404 Not Found nginx/1.10.3 错误

Ubuntu 16.04 中出现 404 Not Found nginx/1.10.3 错误

我正在尝试将我的根目录从 /var/www/html 移动到 ~/website 以便于访问和放宽权限。

这是省略了 IP 的 /var/log/nginx/error.log.1(原始 error.log 列出了现已修复的错误):

2019/08/19 12:26:19 [error] 16659#16659: *90 directory index of "/var/www/html/" is forbidden, client: omitted, server: _, request: "GET / HTTP/1.1", host: "omitted"
2019/08/19 21:41:00 [error] 16659#16659: *116 directory index of "/var/www/html/" is forbidden, client: omitted, server: _, request: "GET / HTTP/1.1", host: "omitted"

为了测试目的,我在 ~/website 目录中只有一个简单的 index.html:

<html>
    <head>
        <title>It worked!</title>
    </head>
    <body>
        <h1>Did it?</h1>
    </body>
</html>

研究告诉我,如果文件本身没有问题,那么配置文件肯定有问题。这是 /etc/nginx/nginx.conf: https://hastebin.com/uquqijiyex.nginx

grep "root" -R /etc/nginx/sites-enabled将返回以下内容:

/etc/nginx/sites-enabled/default:       root ~/website;
/etc/nginx/sites-enabled/default:       # deny access to .htaccess files, if Apache's document root
/etc/nginx/sites-enabled/default:#      root /var/www/example.com;

以下是 /etc/nginx/sites-enabled/default 的内容: https://hastebin.com/iputohokuh.nginx

sudo nginx -t返回时没有错误,并且我已经重新启动了 Nginx。

如果我遗漏了任何信息,请告诉我,我将非常感激您的帮助。

答案1

您不能在 docroot 设置中使用相对路径。请使用完整路径。 /home/USERNAME/website例如。

相关内容