【问题标题】:Nginx with cakephp - configuration problemNginx with cakephp - 配置问题
【发布时间】: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,知道我哪里错了]

【问题讨论】:

标签: cakephp nginx rewrite


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2014-06-03
    • 2012-03-17
    • 2012-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-04
    相关资源
    最近更新 更多