title: 502 Bad Gateway for Laravel 5.4 with nginx and php7.0-fpm in Ubuntu
body: <p>I have my <code>Laravel 5.4</code> app setup in <code>Ubuntu 16.04</code> server with <code>nginx</code> and <code>php7.0-fpm</code>, it gives</p>
  
  <pre><code>502 Bad Gateway
  </code></pre>
  
  <p>Nginx virtualhost config,</p>
  
  <pre><code>server {
      listen   80; ## listen for ipv4; this line is default and implied
      #listen   [::]:80 default ipv6only=on; ## listen for ipv6
  
      root /var/www/html/laravel/public;
      index index.php index.html;
  
      # Make site accessible from http://localhost/
      server_name localhost;
  
      location / {
          try_files $uri $uri/ /index.php?$query_string;
      }
  
      location ~ \.php$ {
          try_files $uri /index.php =404;
          include                  fastcgi_params;
          fastcgi_keep_conn on;
          fastcgi_index            index.php;
          fastcgi_split_path_info  ^(.+\.php)(/.+)$;
          fastcgi_param PATH_INFO $fastcgi_path_info;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          fastcgi_intercept_errors on;
          fastcgi_pass unix:/var/run/php7.0-fpm.sock;
      }
  }
  </code></pre>
  
  <p>Tried the following but still not working,</p>
  
  <p>Changed <code>fastcgi_pass unix:/var/run/php7.0-fpm.sock;</code> to <code>fastcgi_pass 127.0.0.1:9000;</code></p>
  
  <p>Changed <code>try_files   $uri $uri/ /index.php?$query_string;</code> to <code>try_files $uri $uri/ /index.php$is_args$args;</code></p>
  
  <p>Restarted service after each change,</p>
  
  <pre><code>service nginx restart
  service php7.0-fpm restart
  </code></pre>
  
  <p>I can access only the main route with this config,</p>
  
  <pre><code>server {
          listen   80; ## listen for ipv4; this line is default and implied
          #listen   [::]:80 default ipv6only=on; ## listen for ipv6
  
          root /var/www/html/laravel/public;
          index index.html index.htm index.php;
  
          # Make site accessible from http://localhost/
          server_name localhost;
  
          location / {
                  try_files $uri $uri/ =404;
          }
  
          location ~ \.php$ {
                  include snippets/fastcgi-php.conf;
                  fastcgi_pass unix:/run/php/php7.0-fpm.sock;
          }
  
          location ~ /\.ht {
                  deny all;
          }
  }
  </code></pre>