Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fastcgi_param PHP_VALUE 我只在一个站点配置了这个, 为什么其他没有配置的php站点请求也会被捕获了? #10

Closed
laynefyc opened this issue Nov 20, 2017 · 3 comments

Comments

@laynefyc
Copy link
Owner

fastcgi_param PHP_VALUE 我只在一个站点配置了这个, 为什么其他没有配置的php站点请求也会被捕获了?

@laynefyc
Copy link
Owner Author

php-fpm进程会缓存php代码,如果两个站点共用一个php-fpm就会有这种情况。解决办法就是直接在代码的开始执行

require_once('/Users/markstory/Sites/xhgui/external/header.php');
…………

@mcu-shengwei
Copy link

我也遇到了这个问题,如果在项目里引入header文件,对代码具有侵入性而且增加了风险.如果每个项目配置一个fpm的话部署又很麻烦,感觉这个问题无解了。

@kingofzihua
Copy link

我也遇到了这个问题,如果在项目里引入header文件,对代码具有侵入性而且增加了风险.如果每个项目配置一个fpm的话部署又很麻烦,感觉这个问题无解了。

这个可以解决,配置文件里面有个选项可以控制是否开启,在这里可以处理你的逻辑,比如定义一个数组,里面存放你的域名白名单(你也可以定义ip什么的,主要看你的逻辑),这样你就可以控制每个请求,

'profiler.enable' => function() {
        $domainWhiteList = [
             'xxx',
        ];

        return (int) in_array($_SERVER['SERVER_NAME'],$domainWhiteList);
        //return true;//rand(1, 100) === 42;
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants