Permission denied to custom direcotry nginx

2019-08-21 10:03发布

问题:

I created a directory:

data/www

inside it there is a index.html file.

I set this permission to this directory:

sudo chmod -R g+w data/

this is my nginx config:

server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  _;
    root         /usr/share/nginx/html;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
    }

    location /index{
            alias /home/sunyar/data/www/;
            index index.html;
    }
    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}

but I got 403 Forbidden message on my browser:

http://192.168.15.9/index.html

my error message inside log file:

2018/11/05 13:58:23 [error] 13102#0: *5 open() "/home/sunyar/data/www/.html" failed (13: Permission denied), client: 192.168.101.148, server: _, request: "GET /index.html HTTP/1.1", host: "192.168.15.9"
标签: nginx centos