[英]kohana 3.2 + php-fpm + nginx 404
我有一个旧的 kohana 应用程序,我想把它放在我的 VPS 上,但似乎无法让它工作。 我花了好几个小时在谷歌上搜索并查看缓存的论坛答案。 我已经尝试了所有这些,但似乎没有任何效果。 诚然,我不知道如何处理 nginx。 我的本地版本的应用程序在 apache 上运行良好。 我离取消我的 linode 帐户并获得共享主机仅一步之遥! 请叫我离开这个壁架。
我的 VPS 使用 php5-fpm 和 nginx 1.4.6 运行 Ubuntu 14.04 LTS。 我正在从我的用户目录中提供所有内容。
我的 nginx 站点可用文件:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /home/gabreal/Sites/public;
index index.html index.htm index.php;
# Make site accessible from http://localhost/
server_name localhost;
location / {
try_files $uri $uri/ @kohana =404;
}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location @kohana {
rewrite ^/(.+)$ /index.php$request_uri last;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
}
}
我的 Kohana 应用程序在目录中,如下所示:
├──/home/gabreal/Sites/public/
│ ├── horizons/
│ │ ├── grader/ (aka the kohana application)
│ │ │ ├── index.php
│ │ │ ├── application/
│ │ │ ├── system/
当我通过访问http://example.com/horizons/grader
访问应用程序时,kohana 引导程序文件会加载并调用所有重定向。 例如,我的默认路由会将您重定向到起始页。 如果您未登录,请转到“用户/登录”。 网址设置正确。 转到上面的 url,浏览器重定向到http://example.com/horizons/grader/user/login
但我得到了nginx 404 页面。
所以不知何故controller/action
模式无法与此 nginx 设置一起使用。
请帮助你在这个世界上爱你所爱的一切。
更新
仅供参考,我安装了 phpmyadmin,它运行良好。 我仍然无法让 kohana 工作...
更新 2
我重新安装了 kohana 并尝试设置一些基本控制器。 只有默认控制器就像在我的应用程序中一样工作。 因此,转到我的应用程序的基本 url 始终有效,但直接转到任何 /controller/action/id 类型的资源都会在全新安装和现有应用程序上给我nginx 404 错误。
您使用的 nginx 配置不再被视为将 PHP 执行传递回 FPM 的正确方法。 以下示例( 2020 年更新)基于WordPress 文档的原始部分和稍加修改的部分,是一种更适合您的方法。
upstream php {
#this should match value of "listen" directive in php-fpm pool
server unix:/var/run/php5-fpm.sock;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /home/gabreal/Sites/public;
index index.html index.htm index.php;
server_name localhost;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass php;
#The following parameter can be also included in fastcgi_params file
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
请注意,为简洁起见,我没有包括 404 和 50x 处理程序以及.ht
文件保护程序。 您可以将它们从问题中的示例中放回原处。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.