dongzaobei0942 2014-10-22 20:51
浏览 42

NGiNX:来自其他位置的PHP文件+回退到bootstrap index.php

I have two directories having the same structure directory A has all files, directory B only files that differ from A (i. e. an other logo.png). In addition I am running a ZendFramework that has a management and admin module where the bootstrap (index.php) should be triggered.

So www.my.com, www.my.com/admin/ and www.my.com/management should trigger the bootstrap file and all other locations should first been looked up in dir A and then in B and php files should be run from both folders.

I was searching and trying for hours and hours to solve this problem but I think there must be a better or easier way.

Is there?

Strange about it was that either the index.php from ZF was downloaded instead of executed or the other php files where downloaded an not executed. The trick did the part in location ~* \.php$.

  • 写回答

1条回答 默认 最新

  • dongtan9066 2014-10-22 20:51
    关注

    Here we go with my config files

    server {
        ...
    
        root /var/www/clients/B/public/;
    
        # ZendFramework run bootstrap index.php
        location ~ ^/(management|admin)(?:/|\z) {
            try_files $uri $uri/ /index.php$is_args$args;
        }
    
        location ~* \.php$ {
            include php.conf;
            try_files $uri $uri/ @fallbackPHP;
        }
    
        location / {
            try_files $uri $uri/ @fallback;
        }
    
        location @fallback {
            root /var/www/clients/A/public/;
        }
    
        location @fallbackPHP {
            root /var/www/clients/A/public/;
            include php.conf;
        }
    }
    

    and the included php.conf

    try_files $uri =404;
    fastcgi_index index.php;
    fastcgi_pass php5-fpm-sock-B;
    include /etc/nginx/fastcgi_params;
    
    评论

报告相同问题?

悬赏问题

  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序