📜 ⬆️ ⬇️

How to make friends Kohana with nginx and PHP FastCGI

As for nginxa, the notion of .htaccess in its direct form is absent in order for the Kohana framework to handle URLs correctly, you have to write your own nginx config.



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;
}

}


')

Source: https://habr.com/ru/post/100409/


All Articles