1

我有一个项目,我想要在主域 (sitename.org/projectname) 的子文件夹中。这是一个带有 nginx 1.2.0 的 cakephp 1.3 项目。两天的大部分时间里,我一直在网上搜索/尝试解决方案。我最终将添加更多项目作为子文件夹,每个项目都有自己的根。

首先,如果站点位于根域中,则为工作配置。

server {
listen   80;
server_name sitename.org

    location / {
            root /export/home/sitename.org/projectname/app/webroot;
            index index.php index.html index.htm;
            try_files $uri $uri/ /index.php?$uri&$args;

             location ~ .*\.php$ {
                    include /etc/nginx/fastcgi_params;
                     fastcgi_pass 127.0.0.1:9000;
                     fastcgi_index index.php;
                     fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            }


    }

}

我想要工作的是位置是子文件夹(sitename.org/projectname)。我用 try_files 和 fastcgi 尝试了各种配置,但我通常以“未指定输入文件”结束。也就是我的配置错误。

任何提示将不胜感激。

4

1 回答 1

3

通过将根更改为更高的目录和重写路径的组合找到了我的答案。希望这可以帮助遇到类似情况的其他人。

location /projectname {
            root /export/home/sitename.org/;
            index index.php index.html index.htm;
            rewrite ^/projectname/(.*)$ /projectname/app/webroot/$1 break;
            try_files $uri $uri/ /projectname/app/webroot/index.php?q=$uri&$args;

            location ~ .*\.php$ {
                    include /etc/nginx/fastcgi_params;
                     fastcgi_pass 127.0.0.1:9000;
                     fastcgi_index index.php;
                    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

            }
于 2012-11-09T18:00:47.923 回答