title: Nginx, PHP - An error occurred. Sorry, the page you are looking for is currently unavailable. Please try again later
body: <p>I get an error when I access my <code>index.php</code> of my <code>/usr/local/nginx-1.12.2/html</code>.</p>
  
  <pre><code>An error occurred.
  Sorry, the page you are looking for is currently unavailable.
  Please try again later.
  
  If you are the system administrator of this resource then you should check the error log for details.
  
  Faithfully yours, nginx.
  </code></pre>
  
  <hr>
  
  <p>My <code>nginx.conf</code> is this:</p>
  
  <p><code># cat conf/nginx.conf</code>:</p>
  
  <pre><code>worker_processes  1;
  
  events {
      worker_connections  1024;
  }
  
  
  http {
      include       mime.types;
      default_type  application/octet-stream;
  
      sendfile        on;
  
      keepalive_timeout  65;
  
      server {
          listen       80;
          server_name  localhost;
  
          location / {
              root   html;
              index  index.html index.htm index.php;
          }
  
          error_page   500 502 503 504  /50x.html;
          location = /50x.html {
              root   html;
          }
  
          location ~ \.php$ {
              root           html;
              fastcgi_pass   127.0.0.1:9000;
              fastcgi_index  index.php;
              fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
              include        fastcgi_params;
          }
  
      }
  
  }
  </code></pre>
  
  <p>in my <code>/usr/local/php-7.1.16/etc</code>, the <code>php-fpm.conf</code> config is this:</p>
  
  <p><code># cat php-fpm.conf</code></p>
  
  <pre><code>[global]
  pid = /usr/local/php-7.1.16/var/run/php-fpm.pid
  error_log = /usr/local/php-7.1.16/var/log/php-fpm.log
  log_level = notice
  
  [www]
  listen = /tmp/php-cgi.sock
  listen.backlog = -1
  listen.allowed_clients = 127.0.0.1
  listen.owner = www
  listen.group = www
  listen.mode = 0666
  user = www
  group = www
  pm = dynamic
  pm.max_children = 60
  pm.start_servers = 30
  pm.min_spare_servers = 30
  pm.max_spare_servers = 60
  request_terminate_timeout = 100
  request_slowlog_timeout = 0
  slowlog = var/log/slow.log
  </code></pre>
  
  <p>My <code>php-fpm</code> is running. I can use <code>ps -ef | grep php-fpm</code> to check. there are multi processes at there.</p>
  
  <p>my <code>index.php</code> is just a <code>phpinfo()</code>:</p>
  
  <p><code>index.php</code>:</p>
  
  <pre><code>&lt;?php
  
    ini_set("display_errors","On");  
    error_reporting(E_ALL);    
  
    echo phpinfo(); 
  ?&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT-1</strong></p>
  
  <p>In my nginx's <code>error.log</code>:</p>
  
  <pre><code>2018/06/25 09:36:02 [error] 12360#0: *13338 connect() failed (111: Connection refused) while connecting to upstream, client: 118.113.137.192, server: localhost, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "101.103.23.5"
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT-2</strong></p>
  
  <p>Thanks Dan, I changed the <code>fastcgi_pass 127.0.0.1:9000</code> to:</p>
  
  <pre><code>fastcgi_pass   unix:/tmp/php-cgi.sock;
  </code></pre>
  
  <p>But I get the <code>File not found.</code> error, when I access the <code>index.php</code>.</p>