Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save stevepop/c2aee2e51a139a7d1638bb40a272ad82 to your computer and use it in GitHub Desktop.

Select an option

Save stevepop/c2aee2e51a139a7d1638bb40a272ad82 to your computer and use it in GitHub Desktop.

Revisions

  1. @windsting windsting revised this gist Mar 21, 2018. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion nginx-stat-failed-13-permission-denied.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # Nginx: stat() failed (13: permission denied)

    from [StakeOverflow](https://stackoverflow.com/questions/25774999/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
  2. @windsting windsting created this gist Mar 21, 2018.
    29 changes: 29 additions & 0 deletions nginx-stat-failed-13-permission-denied.md
    Original 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
    ```