【问题标题】:ngnix app directory configurationnginx应用目录配置
【发布时间】:2013-09-05 03:38:03
【问题描述】:

我在 nginx 中使用 Procfile 进行男性 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 文件中声明文档根目录

【问题讨论】:

    标签: php heroku yii nginx


    【解决方案1】:

    搜索后我解决了这个问题

    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;
    }
    

    所以它可以配置任何框架

    【讨论】:

    • 您的意思可能是web: vendor/bin/heroku-php-nginx -C custom_nginx.conf myapp/,所以“myapp/”是文档根目录,对吧?你给自己的这个“答案”真的一点都不清楚。
    • 如果你知道然后你可以回复第一个其他明智的我搜索并尝试它的工作。所以不是假的。
    • 我没有说它是假的。我是说您的// add blah here cmets 和您的解释令人困惑。发现这个问题的人不会理解答案。您的问题是如何指定文档根目录(并将其更改为例如myapp/),对吗?
    猜你喜欢
    • 1970-01-01
    • 2016-11-29
    • 1970-01-01
    • 1970-01-01
    • 2016-11-03
    • 1970-01-01
    • 1970-01-01
    • 2015-05-21
    • 1970-01-01
    相关资源
    最近更新 更多