0

I'm trying to set up nginx. When serving a file I get the following error:

[crit] 64347#0: *4 stat() "/home/zmbq/web/static/index.html" failed (13: Permission denied)

I've set the proper permissions to the file and all its parent directories, restart nginx and the error persists.

Running sudo -u nginx cat /home/zmbq/web/static/index.html displays the file's content. stating the same file also works.

Permissions down the path:

[zmbq@csm-web var]$ ll /
drwxr-xr-x.   3 root root   18 Aug 30 09:25 home

[zmbq@csm-web var]$ ll /home
drwxr-xr-x. 13 zmbq zmbq 4096 Aug 30 12:17 zmbq

[zmbq@csm-web var]$ ll /home/zmbq
drwxrwxr-x.  8 zmbq zmbq       77 Aug 30 11:53 web

[zmbq@csm-web var]$ ll /home/zmbq/web
drwxrwxr-x. 4 zmbq nginx 4096 Aug 30 11:46 static

[zmbq@csm-web var]$ ll /home/zmbq/web/static
-rw-rw-r--. 1 zmbq nginx     683 Aug 30 11:46 index.html
zmbq
  • 665
  • 1
  • 7
  • 9
  • 2
    Please show us the permissions you have set. Also: Check SELinux on CentOS. – Sven Aug 30 '18 at 12:37
  • SELinux seems to be enabled, I need to figure out how to see how it applies to the nginx process (the nginx user can access the file). I've added the directory structure with the relevant permissions. – zmbq Aug 30 '18 at 19:23
  • It is SELinux. If I disable it it works, however, none of the tips here: https://stackoverflow.com/q/22586166/871910 seem to work.When it's enabled, I can't access the files. Perhaps I should just copy everything to /usr/share/nginx/html and not worry about it. – zmbq Aug 30 '18 at 19:29
  • You should not put any files in `/usr/share/nginx/html`. That directory is for the nginx default error pages, and is owned by the system package. It may change or disappear unexpectedly. Use a standard directory such as `/srv/www` or a subdirectory thereof. For your answer, see the linked duplicate. – Michael Hampton Aug 31 '18 at 00:10

0 Answers0