I have a problem I can't find an answer too and I'm wondering if I'm doing the named internal location all wrong. Here is an example of my config
location / {
try_files $uri $uri/ @www;
}
location @www {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass myphp;
}
When I go to /index.php I get the index.php recognized as a binary file and the browser just wants to download the file. The file that is downloaded is correct html so I know that the file hit myphp before it was sent to my browser.
If I add this location:
location ~ \.php$ {
fastcgi_pass myphp;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
index.php is displayed in the browser correctly so my question is why does the @www location not correctly handle the php file?
This all started when I tried to setup one nginx server that has multiple php sites under one url that needs a alias for the other sites. Something like this:
root /var/www/somesite;
location / {
index.html index.php;
}
location /wordpress {
alias /var/www/wordpress;
try_files $uri $uri/ @wordpress;
}
....
Can anyone shed some light on how the try_files/named location works? I'm using Nginx 0.8.36 btw