Forked from windsting/nginx-stat-failed-13-permission-denied.md
Created
November 26, 2022 23:01
-
-
Save stevepop/c2aee2e51a139a7d1638bb40a272ad82 to your computer and use it in GitHub Desktop.
Revisions
-
windsting revised this gist
Mar 21, 2018 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # Nginx: stat() failed (13: permission denied) from [https://stackoverflow.com/questions/25774999/nginx-stat-failed-13-permission-denied](https://stackoverflow.com/questions/25774999/nginx-stat-failed-13-permission-denied) Nginx operates within the directory, so if you can't `cd` to that directory from the nginx user then it will fail (as does the `stat` command in your log). Make sure the `www-user` can `cd` all the way to the `/username/test/static`. You can confirm that the stat will fail or succeed by running @@ -27,3 +27,5 @@ For your changes to work, restart nginx ```sh nginx -s reload ``` ## It's the solution for many **permission denied** errors -
windsting created this gist
Mar 21, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ # Nginx: stat() failed (13: permission denied) from [StakeOverflow](https://stackoverflow.com/questions/25774999/nginx-stat-failed-13-permission-denied) Nginx operates within the directory, so if you can't `cd` to that directory from the nginx user then it will fail (as does the `stat` command in your log). Make sure the `www-user` can `cd` all the way to the `/username/test/static`. You can confirm that the stat will fail or succeed by running ```sh sudo -u www-data stat /username/test/static ``` In your case probably the `/username` directory is the issue here. Usually `www-data` does not have permissions to `cd` to other users home directories. The best solution in that case would be to add www-data to username group: ```sh gpasswd -a www-data username ``` and make sure that username group can enter all directories along the path: ```sh chmod g+x /username && chmod g+x /username/test && chmod g+x /username/test/static ``` For your changes to work, restart nginx ```sh nginx -s reload ```