title: Serving php files from different locations in nginx
body: <p>I have my main website and wordpress in different directories on my server on which I use nginx as the web server. The main website is in /home/me/www and Wordpress is in /home/me/wordpress. I need to have them in separate directories this way for a particular reason. How do I specify this in the nginx configuration file? I currently have the following and it does not work:</p>
  
  <pre><code>location / {
      root   /home/me/www;
      index  index.php index.html index.htm;
  }
  
  location /blog {
      root /home/me/wordpress;
      index index.php index.html index.htm;
  }
  
  location ~ \.php$ {
      set $php_root /home/me/www;
      if ($request_uri ~ /blog) {
          set $php_root /home/me/wordpress;
      }
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME  $php_root$fastcgi_script_name;
      include /etc/nginx/fastcgi_params;
  }
  </code></pre>
  
  <p>It currently returns HTTP 404 when I try to access <a href="http://mydomain/blog">http://mydomain/blog</a></p>