title: nginx php-fpm "Access Denied" on Centos
body: <p>I am getting "Access Denied" on index.php file. I created test.php by using touch command on my server and it is working.</p>
  
  <p>I deleted index.php and created index.php by using <code>touch</code> command and c/p index.php source new index.php file and then I checked error.log now the problem is occurred on another php file.</p>
  
  <p>Everything was working and today this problem started. This configuration also was working, there was no change and this problem occurred.</p>
  
  <p>Here is my config files.</p>
  
  <p><code>/etc/nginx/conf.d/default.conf</code> :</p>
  
  <pre><code>server {
  
      listen 80;
      server_name X.X.X.X;
      root /var/www/domain.com;
      index index.php;
  
      location / {
          try_files $uri $uri/ /index.php$is_args$args;
      }
  
      location ~ \.php$ {
          try_files $uri /index.php =404;
          fastcgi_pass 127.0.0.1:9000;
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          include fastcgi_params;
      }
  
      error_page 404 /404.html;
  
      location = /404.html {
          root /var/www/domain.com;
      }
  
      error_page 500 502 503 504 /50x.html;
  
      location = /50x.html {
          root /var/www/domain.com;
      }
  
  }
  </code></pre>
  
  <p><code>/var/www/domain.com/</code> :</p>
  
  <pre><code>drwxr-xr-x.  8 nginx nginx  4096 Nov 16 16:39 .
  drwxr-xr-x.  5 nginx nginx  4096 Oct 30 20:47 ..
  -rwxr-xr-x.  1 nginx nginx   146 Jun  1 18:16 CONTRIBUTING.md
  drwxr-xr-x. 12 nginx nginx  4096 Oct 30 23:36 app
  -rwxr-xr-x.  1 nginx nginx  2452 Jun  1 18:16 artisan
  drwxr-xr-x.  2 nginx nginx  4096 Oct 30 23:36 assets
  drwxr-xr-x.  2 nginx nginx  4096 Oct 30 23:36 bootstrap
  -rwxr-xr-x.  1 nginx nginx   697 Jun  1 18:16 composer.json
  -rwxr-xr-x.  1 nginx nginx 58540 Oct  1 00:19 composer.lock
  -rwxr-xr-x.  1 nginx nginx     0 Jun  1 18:16 favicon.ico
  -rwxr-xr-x.  1 nginx nginx  1580 Oct 31 00:05 index.php
  drwxr-xr-x.  2 nginx nginx  4096 Oct 30 23:36 packages
  -rwxr-xr-x.  1 nginx nginx   567 Jun  1 18:16 phpunit.xml
  drwxr-xr-x.  2 nginx nginx  4096 Oct 30 23:55 public
  -rwxr-xr-x.  1 nginx nginx  2051 Jun  1 18:16 readme.md
  -rwxr-xr-x.  1 nginx nginx    24 Jun  1 18:16 robots.txt
  -rwxr-xr-x.  1 nginx nginx   519 Jun  1 18:16 server.php
  -rwxr-xr-x.  1 nginx nginx    41 Nov 16 16:39 test.php
  drwxr-xr-x. 20 nginx nginx  4096 Oct 30 23:36 vendor
  </code></pre>
  
  <p><code>/etc/nginx/nginx.conf</code> :</p>
  
  <pre><code>user              nginx;
  </code></pre>
  
  <p><code>/etc/php-fpm.d/www.conf</code> :
      user = nginx
      group = nginx</p>
  
  <p><code>/var/log/nginx/error.log</code> :</p>
  
  <pre><code>Unable to open primary script: /var/www/domain.com/index.php (Permission denied)" while reading response header from upstream, client: *, server: *, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "*"
  2014/11/16 18:27:54 [error] 5070#0: *21 FastCGI sent in stderr: "PHP message: PHP Warning:  Unknown: failed to open stream: Permission denied in Unknown on line 0
  </code></pre>
  
  <p>After I deleted index.php and created by using touch command same file:</p>
  
  <pre><code>PHP message: PHP Fatal error:  require(): Failed opening required '/var/www/domain.com/bootstrap/autoload.php'
  </code></pre>