gpt4 book ai didi

nginx - Kohana 似乎不适用于 NGiNX

转载 作者:行者123 更新时间:2023-12-05 06:47:14 26 4
gpt4 key购买 nike

这是我在日志中得到的错误:

2012-08-22 17:20:35 --- ERROR: HTTP_Exception_404 [ 404 ]: Unable to find a route to match the URI: index.php ~ SYSPATH/classes/kohana/request.php [ 1126 ]
2012-08-22 17:20:35 --- STRACE: HTTP_Exception_404 [ 404 ]: Unable to find a route to match the URI: index.php ~ SYSPATH/classes/kohana/request.php [ 1126 ]
--
#0 /var/www/index.php(109): Kohana_Request->execute()
#1 {main}

这是我的 nginx 配置:

server {
listen 80;
server_name 000.000.00.00;

root /var/www;
index index.php;

location / {
try_files $uri $uri/ @kohana;
}

location ~ /\. {
deny all;
}

location ~* \.php$ {
try_files $uri $uri/ @kohana;

fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi_params;
}

location @kohana {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /usr/local/nginx/conf/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
}

#error_page 404 /404.html;

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

在首页我得到:

HTTP_Exception_404 [ 404 ]: Unable to find a route to match the URI: index.php

 DOCROOT/index.php [ 109 ] » Kohana_Request->execute()

在此先感谢您的帮助!

更新

Kohana::init(array(
'base_url' => '/',
));

Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'welcome',
'action' => 'index',
));

最佳答案

我有一个类似的问题,这是我们最终得到的 nginx 配置

server {
listen 80;
server_name <<INSERT SERVER NAME>>;
root /add/root/directory;

index index.php;

# ROUTING TO KOHANA IF REQUIRED
location / {
try_files $uri $uri/ @kohana;
}

# BLOCKS ACCESS TO . FILES (.svn, .htaccess, ...)
location ~ /\. {
deny all;
}

# FOR PHP FILES
location ~* \.php$ {
# PHP FILES MIGHT BE TO HANDLED BY KOHANA
try_files $uri $uri/ @kohana;

fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

# HANDLES THE REWRITTEN URLS TO KOHANA CONTROLLER
location @kohana
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
}

# CACHE CONTROL FOR STATIC FILES
location ~* \.css|\.js|\.jpg|\.jpeg|\.png|\.gif|\.swf|\.svg|\.tiff|\.pdf$ {
expires 30d;
}

# REDIRECTING MEDIAS TO STATIC
location ^~ /medias/ {
rewrite ^/medias/(.*) http://static.xxxx.com/$1 permanent;
break;
}
}

关于nginx - Kohana 似乎不适用于 NGiNX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12081646/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com