Using Yii with Nginx

You are viewing revision #1 of this wiki article.
This version may not be up to date with the latest version.
You may want to view the differences to the latest version.

next (#2) »

The full configuration is here, let's explain it later.

server {
    listen       80;
    server_name  example.com www.example.com;

    charset utf-8;

    access_log  logs/example.access.log  main;

    location / {
        root   /home/yeegt/yiigt;
        index  index.php;
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ ^/protected/ {
        deny  all;
    }

    location ~*.(js|jpg|jpeg|gif|png|ico)$ {
        root /home/example/yii-app;
        expires 356d;
        add_header Cache-Control public;
    }

    location ~ \.php$ {
        root           /home/example/yii-app;
        fastcgi_pass   127.0.0.1:9010;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /home/example/yii-app$fastcgi_script_name;
        include        fastcgi_params;

        set $path_info $request_uri;

        if ($request_uri ~ "^(.*)(\?.*)$") {
            set $path_info $1;
        }
        fastcgi_param PATH_INFO $path_info;
    }
}
18 0
20 followers
Viewed: 65 659 times
Version: Unknown (update)
Category: How-tos
Written by: Leric
Last updated by: grigori
Created on: Feb 28, 2011
Last updated: 6 years ago
Update Article

Revisions

View all history

Related Articles