nginx app目录配置

时间:2013-09-02 05:33:59

标签: php heroku yii nginx

我使用Procfile在nginx中使用nginx自定义配置 所以我用这个代码

创建名为Procfile的新文件
web: vendor/bin/heroku-php-nginx -C nginx_app.conf

和带有此代码的nginx_app.conf的新文件

location / {
    # try to serve file directly, fallback to rewrite
    try_files $uri @rewriteapp;
}

location @rewriteapp {
    # rewrite all to app.php
    rewrite ^(.*)$ /app.php/$1 last;
}

location ~ ^/(app|app_dev|config)\.php(/|$) {
    fastcgi_pass heroku-fcgi;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param HTTPS off;
}

所以在我的heroku应用程序目录中有两个文件夹作为yii(yii框架支持文件),第二个是文档根文件夹,其中是我的应用程序所以我想要两个现在我们必须在nginx_app.conf文件中声明文档根目录

1 个答案:

答案 0 :(得分:0)

搜索后我解决了这个问题

web: vendor/bin/heroku-php-nginx // put your custom nginx file //space with folder name

并删除index.php

location / {
    # try to serve file directly, fallback to rewrite
    try_files $uri @rewriteapp;
}

location @rewriteapp {
    # rewrite all to app.php
    rewrite ^(.*)$ /index.php/$1 last; //add here index.php
}

location ~ ^/(app|app_dev|config)\.php(/|$) {
    fastcgi_pass heroku-fcgi;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param HTTPS off;
}

所以它将配置任何框架