【发布时间】:2011-01-08 08:24:21
【问题描述】:
我设法让它工作了一段时间,但回到我开始的 cakephp 项目时,似乎我最近对 nginx 所做的任何更改(或者可能是最近的更新)都违反了我的重写规则。
目前我有:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.php index.html index.htm;
}
location /basic_cake/ {
index index.php;
if (-f $request_filename) {
break;
}
if (!-f $request_filename) {
rewrite ^/basic_cake/(.+)$ /basic_cake/index.php?url=$1 last;
break;
}
}
location /cake_test/ {
index index.php;
if (-f $request_filename) {
break;
}
if (!-f $request_filename) {
rewrite ^/cake_test/(.+)$ /cake_test/index.php?url=$1 last;
break;
}
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 8081;
server_name localhost;
root /srv/http/html/xsp;
location / {
index index.html index.htm index.aspx default.aspx;
}
location ~ \.(aspx|asmx|ashx|asax|ascx|soap|rem|axd|cs|config|dll)$ {
fastcgi_pass 127.0.0.1:9001;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
我遇到的问题是 CSS 和图像不会从 webroot 加载。相反,如果我访问http://localhost/basic_cake/css/cake.generic.css,我会看到一个页面告诉我:
CakePHP:快速开发php 框架缺少控制器
错误:CssController 不能 找到了。
错误:创建类 CssController 在文件下面: 应用程序/控制器/css_controller.php
注意:如果你想自定义这个 错误信息,创建 应用程序/视图/错误/missing_controller.ctp CakePHP:快速开发的php 框架
有人对如何解决这个问题有任何想法吗?
(我在 ServerFault 上发布了这个,但我觉得与这个相比,没有多少人检查那个站点,所以我可能不应该打扰......)
【问题讨论】: