Nginx和Cakephp .conf文件

时间:2013-08-08 22:28:23

标签: cakephp configuration nginx

我想在Nginx下运行CakePHP 2.x,到目前为止一切正常,除了nginx.conf文件。我目前不知道是否必须修改nginx根文件夹中的nginx.conf文件,或者我是否必须在cakephp webroot文件夹中创建新文件。

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

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

2 个答案:

答案 0 :(得分:0)

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

如果没有尝试我的配置文件。

cakephp2重写-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;

答案 1 :(得分:0)

好吧,我使用这个来源了解它:http://jedistirfry.co.uk/blog/2013-08/cakephp-config-for-nginx/

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