Nginx 404 page not found error due to failed (13: Permission denied)

root@a8cbfa1e38d9:/# cat /var/log/nginx/error.log

2014/07/30 11:23:23 [crit] 370#0: *1 stat() "/usr/share/nginx/html/" failed (13: Permission denied), client: ::1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"

I just did a vanila installation of Nginx in Ubuntu 14.04 but still got a 404 error. I was running in docker saw that the worker threads of nginx were running with user www-data.

root@a8cbfa1e38d9:/usr/share/nginx/html# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 11:21 ? 00:00:00 /bin/bash
root 390 1 0 11:29 ? 00:00:00 nginx: master process nginx
www-data 391 390 0 11:29 ? 00:00:00 nginx: worker process
www-data 392 390 0 11:29 ? 00:00:00 nginx: worker process
www-data 393 390 0 11:29 ? 00:00:00 nginx: worker process
www-data 394 390 0 11:29 ? 00:00:00 nginx: worker process
root 395 1 0 11:29 ? 00:00:00 ps -ef

Doing chown -R www-data:www-data for /usr/share/nginx/ did not help.

So I tracked down the config file where the worker thread user is specified and changed www-data to root to get it working.

Change user in line1 of /etc/nginx/nginx.conf.

Advertisements

2 thoughts on “Nginx 404 page not found error due to failed (13: Permission denied)

  1. Никифор Серяков

    you could just set 755 permissions for every directory on path to root of site (not recursively):
    if site root directory is
    /home/user/work/sites/site1/public_html
    then you should set permissions for dirs:
    chmod 755 ~/work
    chmod 755 ~/work/sites
    chmod 755 ~/work/sites/site1/
    chmod 755 ~/work/sites/site1/public_html

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s