Nginx VHost

The example is for YiiFramework project

server {
        listen 80;
        index index.php;

        root /mnt/projects/yiihaw;
        server_name yiihaw.server.local;

        location / {
                try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include /etc/nginx/fastcgi_params;
        }

        location = /(favicon.ico|robots.txt)$ {
                log_not_found off;
                access_log off;
        }       

        location ~ /((protected|framework|nbproject)|\.) {
                deny all;
                access_log off;
                log_not_found off;
        }
}

Leave a Reply