Так как Ваши проекты не находятся на самом деле в том же корне, необходимо использовать несколько местоположений для этого.
location /wiki {
root /var/www/wiki/public;
}
location ~ /wiki/.+\.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/wiki/public$fastcgi_script_name;
}
location /blog {
root /var/www/blog/public;
}
location ~ /blog/.+\.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/blog/public$fastcgi_script_name;
}
Кроме того, помещенные fastcgi_index в Вашем fastcgi_params файле и включают его в уровень сервера, тот способ, которым Вы сохраняете свои php местоположения как можно меньше.
Решает location+alias:
location / {
root /var/www/public;
index index.php;
}
location /blog/ {
alias /var/www/blog/public/;
index index.php;
}
location /wiki/ {
alias /var/www/wiki/public/;
index index.php;
}
location ~ \.php$ {
#your fastcgi configuration here
}
Вот то, что я пробовал, подробности на http://programmersjunk.blogspot.com/2013/11/nginx-multiple-sites- in-subdirectories.html
location /Site1/ {
root /usr/share/nginx/www/Site1;
try_files $uri $uri/ /index.php?$query_string;
}
# the images need a seperate entry as we dont want to concatenate that with index.php
location ~ /Site1/.+\.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
root /usr/share/nginx/www/Site1;
}
# pass the PHP scripts to FastCGI server
location ~ /Site1/.+\.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
allow 127.0.0.1;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
}
location /Site3/ {
root /usr/share/nginx/www/Site3;
}
# pass the PHP scripts to FastCGI server
location ~ /Site3/.+\.php$ {
allow 127.0.0.1;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
#we are directly using the $request_filename as its a single php script
fastcgi_param SCRIPT_FILENAME $request_filename;
}