【发布时间】:2012-09-16 01:44:46
【问题描述】:
我是卡提克。这是我在这里的第一篇文章。
我有一个使用 nginx 服务器在 centos 上运行的 vps。我想在我的网站上建立一个相册。所以我创建了一个子域 clicks.example.com。我正在使用一个名为whitespace cms 的flash 模板,它使用cakephp。问题在于重写规则。我无法找出根目录。
这是我的配置文件。
server {
listen 80;
server_name clicks.example.com;
access_log /home/www/example.com/logs/access.log;
error_log /home/www/example.com/logs/error.log;
rewrite_log on;
# rewrite rules for cakephp
location / {
root /home/www/example.com/clicks/fotoblog/app/webroot/;
index index.php index.html;
# If the file exists as a static file serve it
# directly without running all
# the other rewite tests on it
if (-f $request_filename) {
break;
}
if (!-f $request_filename) {
rewrite ^/(.+)$ /index.php?url=$1 last;
break;
}
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/www/example.com/clicks/fotoblog/app/webroot$fastcgi_script_name;
include fastcgi_params;
}
}
我想我弄乱了 cakephp 的子域和根目录。任何帮助将不胜感激。我尝试了 8 个小时 :) 仍然没有运气。当我使用上述配置时,我得到空白页,有时我得到一个 502 bad gateway 错误。 更新:好的,502 错误是由于 nginx php-fpm 问题。现在,当我访问 clicks.example.com 时,我会被重定向到黑色的 cms。 clicks.example.com/users/login.. [其实后台应该是clicks.example.com/fotoblog/users/login,知道我哪里错了]
【问题讨论】:
-
在这里查看我对类似问题的回答:stackoverflow.com/questions/8088717/…