title: Multiple PHP based server blocks in nginx - 404 Error
body: <p>I am pretty new in Nginx and I have a problem with it. I have two wordpress websites and I want to start them with Nginx on a Centos Linux. What I have done is:</p>
  
  <ol>
  <li>creating sites-available and sites-enabled in the /etc/nginx/</li>
  <li>Put my website configuration files (.conf) into sites-available</li>
  <li>I created symbolic links for them using <code>ln -s</code></li>
  </ol>
  
  <p>My configuration files are as follow:
  <strong>nginx.conf</strong></p>
  
  <pre><code>http {
      log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';
  
      access_log  /var/log/nginx/access.log  main;
  
      sendfile            on;
      tcp_nopush          on;
      tcp_nodelay         on;
      keepalive_timeout   65;
      types_hash_max_size 2048;
  
      default_type        application/octet-stream;
  
      # Load modular configuration files from the /etc/nginx/conf.d directory.
      # See http://nginx.org/en/docs/ngx_core_module.html#include
      # for more information.
    #   include /etc/nginx/conf.d/*.conf
      server {
          listen       80 default_server;
          listen       [::]:80 default_server;
          server_name  _;
          root         /usr/share/nginx/html;
          index        index.html;
          # Load configuration files for the default server block.
          include /etc/nginx/default.d/*.conf;
  
          location / {
          }
      location ~ \.php$ {
          try_files $uri =404;
          fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
          fastcgi_index index.php;
          include fastcgi_params;
      }
  
          error_page 404 /404.html;
              location = /40x.html {
          }
  
          error_page 500 502 503 504 /50x.html;
              location = /50x.html {
          }
      }
  include /etc/nginx/sites-enabled/*.conf;
  server_names_hash_bucket_size 64;
  }
  </code></pre>
  
  <p><strong>mydomain1.com.conf</strong></p>
  
  <pre><code>server {
      listen 80;
      server_name mydomain1.com www.mydomain1.com;
      location / {
          root /var/www/html/;
          index index.php;
      }
      location ~ \.php$ {
          try_files $uri =404;
          fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
          fastcgi_index index.php;
          include fastcgi_params;
      }
  
  }
  </code></pre>
  
  <p><strong>mydomain2.com.conf</strong></p>
  
  <pre><code>server {
      listen 80;
      server_name mydomain2.com www.mydomain2.com;
      location / {
          try_files $uri $uri/ =404;
          root /var/www/aramis;
          index index.php;
      }
      location ~ \.php$ {
          try_files $uri =404;
          fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
          fastcgi_index index.php;
          include fastcgi_params;
      }
  
  }
  </code></pre>
  
  <p><strong>/etc/php-fm.d/www.conf</strong></p>
  
  <pre><code>[www]
  listen = /var/run/php-fpm/php-fpm.sock
  listen.allowed_clients = 127.0.0.1
  listen.owner = nobody
  listen.group = nobody
  ;listen.mode = 0660
  user = nginx
  group = nginx
  pm = dynamic
  pm.max_children = 50
  pm.start_servers = 5
  pm.min_spare_servers = 5
  pm.max_spare_servers = 35
  php_admin_value[error_log] = /var/log/php-fpm/www-error.log
  php_admin_flag[log_errors] = on
  php_value[session.save_handler] = files
  php_value[session.save_path] = /var/lib/php/session
  </code></pre>
  
  <p>I also tried to find php-fpm.sock but I was not successful.
  What I get when try to see my websites from browser is <strong>404 Error.</strong></p>