Muhammad Mudassir
Muhammad Mudassir

Reputation: 331

Angular4 and NGINX permission denied

I'm unable to run my angular 4 app using nginx. I have checked error.log for nginx i see this

2018/04/21 12:49:52 [error] 13961#13961: *1 open() "/root/test/myapp/web-portal/index.html" failed (13: Permission denied)

I'm running all commands using sudo. My nginx configuration is

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;
        }

}

I have tried chmod but not working for me

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

Upvotes: 0

Views: 457

Answers (1)

David
David

Reputation: 34465

It's not a very good practice to run nginx as root.

You should rather create a user for nginx (if you don't already have one) and then place the website files in a directory whose owner is the nginx user, such as /var/www

Upvotes: 1

Related Questions