【问题标题】:Nginx and Cakephp .conf fileNginx 和 Cakephp .conf 文件
【发布时间】:2013-08-10 19:53:44
【问题描述】:

我想在 Nginx 下运行 CakePHP 2.x,到目前为止一切正常,除了 nginx.conf 文件。目前不知道是要修改nginx根目录下的nginx.conf文件还是要在cakephp webroot目录下新建一个文件。

我也不确定文件的内容,我在网上找到了几个例子,但它们在细节上有所不同。

是否有一个很好的资源可以详细解释如何设置?

【问题讨论】:

    标签: cakephp configuration nginx


    【解决方案1】:

    好的,我使用以下来源:http://jedistirfry.co.uk/blog/2013-08/cakephp-config-for-nginx/

    我编辑了 nginx.conf 主文件(在 nginx 的“conf”文件夹内),特别是监听端口 80 的“服务器”部分。

    【讨论】:

      【解决方案2】:

      你试过了吗? http://book.cakephp.org/2.0/en/installation/url-rewriting.html#pretty-urls-on-nginx

      如果不试试我的配置文件。

      cakephp2-rewrite-rules.conf

      if (-f $request_filename) { 
          break; 
      }     
      if (!-f $request_filename) {
          rewrite ^/(.+)$ /index.php?url=$1 last;
          break;
      }
      

      cake2app.conf

      location / {
          index index.html index.htm index.php;
          allow all;
          include cakephp2-rewrite-rules.conf;
      }
      include php-fastcgi.conf;
      

      vhosts.conf

      server {
        root          /foo/bar;
        listen        vhost:80;
        server_name   vhost;
        include       vhost/cake2app.conf;
      }
      

      在 http 部分的 nginx.conf 中包含 vhosts.conf。

      include vhost/vhosts.conf;
      

      【讨论】:

      • 我是把这段代码放在主 nginx.conf 文件中还是在 webroot 文件夹中创建一个新的 nginx.conf 文件?
      猜你喜欢
      • 2016-07-15
      • 1970-01-01
      • 2017-07-25
      • 2021-10-02
      • 2011-02-25
      • 2015-06-02
      • 1970-01-01
      • 2023-04-02
      • 2013-03-23
      相关资源
      最近更新 更多