I am converting a legacy Apache server to Nginx and do not have the luxury of changing URL's or rearranging the filesystem.
Is it possible to use nested location{} blocks in the Nginx configuration to tell it to feed the .php files in an aliased directory to fastcgi while serving static content normally?
Similar configuration to what fails me:
server {
listen 80;
location / {
index index.html;
}
location /foosite/ {
alias /var/aliases/foo;
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
}
Requests for /foosite/static.jpg are served fine, but nginx appears to garble the path to any .php files when attempting to dispatch them to fastcgi.
Best Answer
The solution provided here is not a solution. And it's not correct anymore. Using Lucid (10.4) I was able to use this solution. The problem with womble's solution is that it doesn't set the
DOCUMENT_ROOT
parameter properly; rather, it includes the script name in the document_root.This seems to work OK.
Using
nginx/0.7.65