自定义目录nginx

时间:2018-11-05 10:29:20

标签: nginx centos

我创建了一个目录:

data/www

里面有一个index.html文件。

我对此目录设置了此权限:

sudo chmod -R g+w data/

这是我的Nginx配置:

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

但是我在浏览器中收到403 Forbidden条消息:

http://192.168.15.9/index.html

我在日志文件中的错误消息:

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"

0 个答案:

没有答案