I'd like to have one virtual server handling many different locations. So, I started with a following basic config:
[code]
server {
listen 80 default;
server_name my.server.name;
location / {
root /my/root/location;
index index.html index.htm;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:MYPORT;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /my/root/location$fastcgi_script_name;
include fastcgi_params;
}
}
[/code]
Everything worked as it should.
So I decided to add my first, additional location:
[code]
location ^~ /my_first_loc {
alias /my/first/loc/;
}
[/code]
And all the html files were served properly.
My problems began when I was trying to get PHP files located in my first location to work properly. I added the following location:
[code]
location ~ /my_first_loc/.*\.php$ {
fastcgi_pass 127.0.0.1:MYPORT;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /my/first/loc$fastcgi_script_name;
include fastcgi_params;
}
[/code]
but all I got was the bare .php file - it was served by Nginx, instead of being sent to PHP interpreter.
What did I do wrong? Is it my config that is wrong, or is it my approach to solve my problem (should I do it in a different way)? (And my problem is: how to properly serve PHP files from many different locations?)