Here is what I have in ls -al /etc/nginx:total 52drwxr-xr-x.  4 root root 4096 Jul 28 04:16 .drwxr-xr-x. 78 root root 8192 Jul 28 03:37 ..drwxr-xr-x.  2 root root   26 Jul 28 03:55 conf.ddrwxr-xr-x.  2 root root    6 May 10 09:21 default.d-rw-r--r--.  1 root root 1034 May 10 09:21 fastcgi.conf-rw-r--r--.  1 root root  964 May 10 09:21 fastcgi_params-rw-r--r--.  1 root root 2837 May 10 09:21 koi-utf-rw-r--r--.  1 root root 2223 May 10 09:21 koi-win-rw-r--r--.  1 root root 3957 May 10 09:21 mime.types-rw-r--r--.  1 root root 1033 Jul 28 03:43 nginx.conf-rw-r--r--.  1 root root  596 May 10 09:21 scgi_params-rw-r--r--.  1 root root  623 May 10 09:21 uwsgi_params-rw-r--r--.  1 root root 3610 May 10 09:21 win-utfThis is what I see /var/log/nginx/error.log after sudo service nginx start:[emerg] 20360#0: open() /etc/nginx/conf.d/foo.conf failed(13: Permission denied) in /etc/nginx/nginx.conf:33This is what I have in ls -al /etc/nginx/conf.d/:$ ls -al /etc/nginx/conf.d/total 8drwxr-xr-x. 2 root root   26 Jul 28 03:55 .drwxr-xr-x. 4 root root 4096 Jul 28 04:16 ..-rw-r--r--. 1 root root  230 Jul 28 03:50 foo.confWhat's wrong?
Nginx says open() /etc/nginx/conf.d/foo.conf failed (13: Permission denied)
centos;nginx
When you are getting permission denied errors on file access etc. for unknown reason, it might be related to SELinux.  Especially when you see a period following permissions like drwxr-xr-x. shown by ls -l for the file/dir in question, they could be mislabeled (you can see it by ls -Z) and cause the problem.You should first check current SELinux mode by running getenforce.  If it says Enforcing, then temporarily set the mode to Permissive by running setenforce 0, and see if your application works afterwards.Please consult your distribution's guide on SELinux for permanent fix, including setting the SELinux mode on start up, relabeling files or directories, updating policies, etc.  Here's Howto for CentOS.