title: Nginx + php5-fpm = 404 Error with alias location
body: <p>I am an amateur front end web developer, and I recently bought a Ubuntu server to try to my hand at some backend development. I am trying to figure out how to serve a php file from an aliased location block using php5-fpm. I am getting a 404 - Page not found error. I have tried all of the proposed solutions I could find here with no luck. As I am still a beginner I would love a quick ELI5 as well and any pointers on the rest of my conf file, so I can learn something too. I should mention that the main root folder is running a flask app, and is the reason I am using an aliased location.</p>
  
  <p>My virtual host:</p>
  
  <p>Nginx conf file</p>
  
  <pre><code>server {
  listen 80;
  listen [::]:80;
  server_name www.example.com example.com;
  
  root /var/www/example;
  large_client_header_buffers 8 32k;
  access_log /var/www/example/logs/access.log;
  error_log /var/www/example/logs/error.log;
  
  
  location / {
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $remote_addr; #$proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;
      proxy_pass http://app_test;
      proxy_redirect off;
  }
  
  
   location /test_site {
       alias /var/www/test_site;
       index index.php index.html index.htm;
       location ~ .php$ {
                  try_files $uri =404;
                  fastcgi_split_path_info ^(.+?\.php)(/.*)?$;
                  fastcgi_pass unix:127.0.0.1:9000;
                  fastcgi_index index.php;
                  include fastcgi_params;
       }
    }
  </code></pre>
  
  <p>php5 www.conf file</p>
  
  <pre><code>[www]
  ...
  user = www-data
  group = www-data
  
  
  listen = 127.0.0.1:9000
  #listen = /tmp/php5-fpm.sock
  
  listen.owner = www-data
  listen.group = www-data
  listen.mode = 0660
  ...
  </code></pre>
  
  <p>My fastcgi_params file is default. I have checked both the php and nginx logs and there are no errors. Any help would be much appreciated! </p>