nginxとPHP FastCGIでKohanaを友達にする方法

nginxaの場合、.htaccessの概念は直接の形式では存在しないため、Kohanaフレームワークを使用した正しいURL処理のために、nginxの独自の構成を作成する必要があります。







server {

listen xx.xx.xx.xx:80;

server_name ;



access_log /var/log/nginx/localhost.access.log;



if ($request_filename !~ (js|css|images|robots\.txt|index\.php.*) ) {

rewrite ^(.+)$ /index.php?$1 last;

}



location ~ \.php {

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;



include fastcgi_params;

fastcgi_param SCRIPT_FILENAME /var/www/$fastcgi_script_name;

fastcgi_param QUERY_STRING $query_string;

fastcgi_param REQUEST_METHOD $request_method;

fastcgi_param CONTENT_TYPE $content_type;

fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;

access_log off;

}



location / {

root /var/www;

index index.php;

}

}





. :



server {

listen xx.xx.xx.xx:80;

server_name ;



access_log /var/log/nginx/localhost.access.log;



location / {

try_files $uri $uri/ @kohana;

}



location @kohana {

fastcgi_pass 127.0.0.1:9000;

fastcgi_param SCRIPT_FILENAME /var/www/index.php;

fastcgi_param QUERY_STRING $uri;

include fastcgi_params;

}



}














All Articles