我已经使用php5-xhprof在debian 7上安装了xhprof。
这创建了一个文件/etc/php5 5/fpm/conf.d.d/20-xhprof.ini。
在ini文件中,我添加了xhprof.output_dir="/tmp/xhprof“
我用755 www-data:www-data创建了/tmp/xhprof文件
我可以确认php使用phpinfo()启用了xhprof,尽管它没有提供output_dir参数。
我运行的脚本有第一行
xhprof_enable(XHPROF_FLAGS_NO_BUILTINS | XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);在/tmp/xhprof中没有创建任何文件
我已经重新启动php5-fpm,但仍然没有运气。
发布于 2015-09-25 02:03:17
xhprof.output_dir字符串 iXHProfRuns接口(即XHProfRuns_Default类)的默认实现用于存储XHProf的目录。
http://php.net/manual/en/xhprof.configuration.php
在分析(或脚本)结束时,需要手动保存数据。
$xhprof_data = xhprof_disable();
$XHPROF_ROOT = "/tools/xhprof/";
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_testing");
echo "http://localhost/xhprof/xhprof_html/index.php?run={$run_id}&source=xhprof_testing\n";http://php.net/manual/en/xhprof.examples.php
如果不想在应用程序代码中控制分析,可以自动加载代码片段/path/to/xhprof/xhprof_enabler.php
<?php
xhprof_enable(XHPROF_FLAGS_NO_BUILTINS | XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);
register_shutdown_function(function(){
$xhprof_data = xhprof_disable();
$XHPROF_ROOT = "/path/to/xhprof";
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_testing");
echo "http://localhost/xhprof/xhprof_html/index.php?run={$run_id}&source=xhprof_testing";
});然后添加
auto_prepend_file=/path/to/xhprof/xhprof_enabler.php转到/etc/php5/fpm/conf.d/20-xhprof.ini
请注意,还需要设置虚拟主机以查看配置文件,或者只需将xhprof文件夹(包含xhprof_html)符号链接到默认的vhost根目录即可。
重新启动php5-fpm,您应该完成。
https://stackoverflow.com/questions/32728931
复制相似问题