<div dir="ltr">I've been struggling with this for a few hours. <br><br>I installed nginx 1.4.6 on Fedora 20. The test page displayed fine. I changed the root, leaving all other configuration the same, and I get a 403 Forbidden error. <br>
<br>If I look at the permissions for the original test page and the new page, they appear identical.<br><br>Working test page:<br>namei -om /usr/share/nginx/html/index.html<br>f: /usr/share/nginx/html/index.html<br>dr-xr-xr-x root root /<br>
drwxr-xr-x root root usr<br>
drwxr-xr-x root root share<br>drwxr-xr-x root root nginx<br>drwxr-xr-x root root html<br>-rw-r--r-- root root index.html<br><br>Not working:<br>namei -om /var/www/html/index.html<br>f: /var/www/html/index.html<br>dr-xr-xr-x root root /<br>
drwxr-xr-x root root var<br>drwxr-xr-x root root www<br>drwxr-xr-x root root html<br>-rw-r--r-- root root index.html<br><br>The error log seems to be what I would expect as well:<br>2014/03/23 12:45:08 [error] 5490#0: *13 open() "/var/www/html/index.html" failed (13: Permission denied), client: XXX.XX.XXX.XXX, server: localhost, request: "GET /index.html HTTP/1.1", host: "<a href="http://ec2-XXX-XX-XXX-XXX.compute-1.amazonaws.com" target="_blank">ec2-XXX-XX-XXX-XXX.compute-1.amazonaws.com</a>"<br>
<div><br></div><div>The Nginx config has "user nginx" - I tried using root and it made no difference. I also made user ngnix the owner & group of the files, but that didn't work. If I move the index file from /var/www/html to /usr/share/nginx/html (the test file location) it works fine making me suspect the path, but as I said, permissions appear correct. </div>
<div><br></div><div>Any help would be very much appreciated. Thanks!</div><div><br></div><div>- Adam</div><div><br></div><div>I've included the config file below just in case:<br></div><br># For more information on configuration, see:<br>
# * Official English Documentation: <a href="http://nginx.org/en/docs/">http://nginx.org/en/docs/</a><br># * Official Russian Documentation: <a href="http://nginx.org/ru/docs/">http://nginx.org/ru/docs/</a><br><br>user nginx;<br>
worker_processes 1;<br><br>error_log /var/log/nginx/error.log;<br>#error_log /var/log/nginx/error.log notice;<div>#error_log /var/log/nginx/error.log info;<br><br>pid /run/nginx.pid;<br><br>events {<br> worker_connections 1024;<br>
}<br><br>http {<br> include /etc/nginx/mime.types;<br> default_type application/octet-stream;<br><br> log_format main '$remote_addr - $remote_user [$time_local] "$request" '<br> '$status $body_bytes_sent "$http_referer" '<br>
'"$http_user_agent" "$http_x_forwarded_for"';<br><br> access_log /var/log/nginx/access.log main;<br><br> sendfile on;<br> #tcp_nopush on;<br><br> #keepalive_timeout 0;<br>
keepalive_timeout 65;<br><br> #gzip on;<br><br> # Load modular configuration files from the /etc/nginx/conf.d directory.<br> # See <a href="http://nginx.org/en/docs/ngx_core_module.html#include" target="_blank">http://nginx.org/en/docs/ngx_core_module.html#include</a><br>
# for more information.<br> include /etc/nginx/conf.d/*.conf;<br><br> index index.html index.htm;<br><br> server {<br> listen 80;<br> server_name localhost;<br> root /usr/share/nginx/html; ################THIS WORKS<br>
#root /var/www/html; #####################THIS DOESN'T<br><br> #charset koi8-r;<br><br> #access_log /var/log/nginx/host.access.log main;<br><br> location / {<br> }<br><br>
# redirect server error pages to the static page /40x.html<br> #<br> error_page 404 /404.html;<br> location = /40x.html {<br> }<br><br> # redirect server error pages to the static page /50x.html<br>
#<br> error_page 500 502 503 504 /50x.html;<br> location = /50x.html {<br> }<br><br> # proxy the PHP scripts to Apache listening on <a href="http://127.0.0.1:80" target="_blank">127.0.0.1:80</a><br>
#<br> #location ~ \.php$ {<br> # proxy_pass <a href="http://127.0.0.1" target="_blank">http://127.0.0.1</a>;<br> #}<br><br> # pass the PHP scripts to FastCGI server listening on <a href="http://127.0.0.1:9000" target="_blank">127.0.0.1:9000</a><br>
#<br> #location ~ \.php$ {<br> # root html;<br> # fastcgi_pass <a href="http://127.0.0.1:9000" target="_blank">127.0.0.1:9000</a>;<br> # fastcgi_index index.php;<br>
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;<br> # include fastcgi_params;<br> #}<br><br> # deny access to .htaccess files, if Apache's document root<br> # concurs with nginx's one<br>
#<br> #location ~ /\.ht {<br> # deny all;<br> #}<br> }<br><br> # another virtual host using mix of IP-, name-, and port-based configuration<br> #<br> #server {<br> # listen 8000;<br>
# listen somename:8080;<br> # server_name somename alias another.alias;<br> # root html;<br><br>
# location / {<br> # }<br> #}<br><br><br> # HTTPS server<br> #<br> #server {<br> # listen 443;<br> # server_name localhost;<br> # root html;<br>
<br> # ssl on;<br> # ssl_certificate cert.pem;<br> # ssl_certificate_key cert.key;<br><br> # ssl_session_timeout 5m;<br><br> # ssl_protocols SSLv2 SSLv3 TLSv1;<br> # ssl_ciphers HIGH:!aNULL:!MD5;<br>
# ssl_prefer_server_ciphers on;<br><br> # location / {<br> # }<br> #}<br><br>}</div></div>