title: Nginx Configuration throws 500 Internal Server Error
body: <p>According to error.log:</p>
  
  <pre><code>2016/05/10 16:48:27 [crit] 11638#0: *1 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to client upstream, client: 123.456.789, server: example.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:"
  </code></pre>
  
  <p>And below is the content of "/etc/nginx/sites-available/default":</p>
  
  <pre><code>server {
      listen 80 default_server;
      listen [::]:80 default_server ipv6only=on;
  
      #root /usr/share/nginx/html;
      root /var/www;
      index index.php index.html index.htm;
  
      # Make site accessible from http://localhost/
      server_name example.com;
  
      location / {
          # First attempt to serve request as file, then
          # as directory, then fall back to displaying a 404.
  
          try_files $uri $uri/ /index.html;
  
          # Uncomment to enable naxsi on this location
          # include /etc/nginx/naxsi.rules
      }
  
      location @handler{
          rewrite / /index.php;
      }
  
      location /doc {
          root /usr/share;
          autoindex on;
          allow 127.0.0.1;
          deny all;
      }
  
      location /images {
          root /usr/share;
          autoindex off;  
      }
  
      # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
      #location /RequestDenied {
      #   proxy_pass http://127.0.0.1:8080;    
      #}
  
      error_page 404 /404.html;
  
      # redirect server error pages to the static page /50x.html
      #
      error_page 500 502 503 504 /50x.html;
      location = /50x.html {
          #root /usr/share/nginx/html;
          root /var/www;
      }
  
      # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
      #
      location ~* \.php$ {
      #   try_files $uri=404;
      #   fastcgi_split_path_info ^(.+\.php)(/.+)$;
      #   # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
      #
      #   # With php5-cgi alone:
      #   fastcgi_pass 127.0.0.1:9000;
      #   # With php5-fpm:
      #   fastcgi_pass unix:/var/run/php5-fpm.sock;
      #   fastcgi_index index.php;
      #   fastcgi SCRIPT_FILENAME $document_root$fastcgi_script_name;
      #   include fastcgi_params;
  
          try_files $uri =404;
          include /etc/nginx/fastcgi_params;
          fastcgi_pass unix:/var/run/php5-fpm.sock;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          fastcgi_intercept_errors on;
      }
  
      # deny access to .htaccess files, if Apache's document root
      # concurs with nginx's one
      #
      #location ~ /\.ht {
      #   deny all;
      #}
  }
  </code></pre>
  
  <p>When i do ls /var/run/ i don't see any php5-fpm.sock file (even though i have "sudo service php5-fpm start" or "sudo service php5-fpm restart"). I am not sure why is this happening.</p>
  
  <p>I am relatively new with nginx, and currently experimenting nginx with magento. Basically am trying to install Magento using nginx.</p>
  
  <p>When i browse to example.com, instead of seeing default magento installation i get "500 Internal Server Error" message.</p>
  
  <p>The configuration above is based on multiple references:</p>
  
  <pre><code>https://thomas-leister.de/linux/nginx-php-fpm-installieren-ubuntu-server/
  </code></pre>
  
  <p>and</p>
  
  <pre><code>https://www.howtoforge.de/anleitung/installation-von-nginx-mit-php5-und-php-fpm-mit-mysql-unterstutzung-unter-ubuntu-11-10/
  </code></pre>
  
  <p>Can anyone help me with this ? Thank you.</p>
  
  <p>EDIT 1:
  I am using Ubuntu 14.04 (AWS EC2).</p>
  
  <p>EDIT 2:
  <a href="https://i.stack.imgur.com/0W1m2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0W1m2.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/zOlfo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zOlfo.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/MoKWa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MoKWa.png" alt="enter image description here"></a></p>
  
  <p>EDIT 3:
  <a href="https://i.stack.imgur.com/jK9YJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jK9YJ.png" alt="enter image description here"></a></p>