I'm also new to nginx, Here is my solution that is similar with Mohammad AbuShady's answer :
sites-enabled/default
whatever.conf
in /etc/nginx/conf.d/
The reason is:
sites-enabled/default
has defined a serverthat is listening on 80 rooting with /var/www/html
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
nginx.conf
file includes other conf filesinclude /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
the 1st edition of my.conf is root on /home/myusername/, but will get 403 Forbidden error, check the error.log:
2016/04/07 20:12:44 [error] 12466#0: *2 open() "/home/myusername/data/a" failed (13: Permission denied),
client: 127.0.0.1, server: , request: "GET /a HTTP/1.1", host: "localhost"