【问题标题】:Angular4 and NGINX permission deniedAngular4 和 NGINX 权限被拒绝
【发布时间】:2018-10-02 00:30:02
【问题描述】:

我无法使用 nginx 运行我的 Angular 4 应用程序。我已经检查了 nginx 的 error.log 我看到了这个

2018/04/21 12:49:52 [错误] 13961#13961: *1 open() “/root/test/myapp/web-portal/index.html”失败(13: 权限被拒绝)

我正在使用 sudo 运行所有命令。我的 nginx 配置是

server {
        listen 80 default_server;
        listen [::]:80 default_server;


        # Add index.php to the list if you are using PHP

        root /root/test/myapp/web-portal/index.html;
        index index.html index.htm index.nginx-debian.html;

        server_name _;
        location /admin {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.


                try_files $uri /index.html =404;
        }

}

我尝试了 chmod 但对我不起作用

chmod -R 755 /root/test/myapp/web-portal

【问题讨论】:

  • 可能是端口问题,所以尝试在1023以上的端口上运行
  • 显示索引文件和父文件夹的权限。哪个用户在运行 nginx?

标签: angular nginx ubuntu-14.04


【解决方案1】:

以 root 身份运行 nginx 并不是一个很好的做法。

您应该为 nginx 创建一个用户(如果您还没有),然后将网站文件放在所有者为 nginx 用户的目录中,例如/var/www

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-25
    • 2021-03-27
    • 2017-11-03
    • 2016-03-26
    • 2020-02-08
    • 2014-03-31
    • 2018-12-15
    相关资源
    最近更新 更多