How To Configure Yii2 Website With Nginx Location?

I have single domain ( and several Yii2-based web-sites. I need to configure Nginx to open each web-site in location, ex., with url rewrite support. Im using Debian 7.0.5. I could not use subdomains in this scenario.

My config is:

server {

	charset utf-8;

	client_max_body_size 128M;

	listen 80;

	root /var/www;

	index index.php;

	error_log /var/log/nginx/error.log debug;

	location /site1/ {

		alias /var/www/site1/web/;

		try_files $uri $uri/ /index.php?$args;

		location ~ ^/site1/(.+\.php)$ {

			include yii.conf;

			fastcgi_param SCRIPT_FILENAME /var/www/test/web/index.php;



	location ~ /\.(ht|svn|git) {

		deny all;



Yii.conf file:

fastcgi_split_path_info ^(.+\.php)(/.+)$;

fastcgi_hide_header "X-Powered-CMS";

fastcgi_hide_header "X-Powered-By";

fastcgi_pass unix:/var/run/php5-fpm.sock;

include fastcgi_params;

Please help.

Did you ever get this figured out?

try this