Nginx与cakephp - 配置问题

时间:2011-05-18 13:19:58

标签: cakephp nginx rewrite

我是karthik。这是我在此的头一篇博文。

我有一个使用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错误的网关错误。 更新:好的,502错误是由于nginx php-fpm问题。现在,当我访问clicks.example.com时,我被重定向到cms的变黑。 clicks.example.com/users/login .. [实际上后台应该是clicks.example.com/fotoblog/users/login,请知道我哪里出错了]

1 个答案:

答案 0 :(得分:0)

你没有做错任何事!我也遇到了类似的问题,并且经过数小时的研究和浪费时间后能够修复它 - 我只是重新安装了一个新的Cake版本,它解决了我的nginx rewrite rule issues