网上关于xdebug安装的文章很多了,这里不啰嗦了,一笔带过
安装配置
下载PHP的XDebug扩展,网址:http://xdebug.org/
在Linux下编译安装XDebug
老办法
1 phpize
2 ./configure --enable-xdebug
3 make
4 复制modules/xdebug.so 到php的ext目录
5 编辑php.ini,在最下方增加
zend_extension_ts="/opt/php5/xdebug.so"
xdebug.profiler_enable=on
xdebug.trace_output_dir="/tmp/xdebug"
xdebug.profiler_output_dir="/tmp/xdebug"
xdebug.profiler_output_name="cachegrind.out.%s"
注意:xdebug.profiler_output_name 这一步折腾了很久,直接copy文档的说明吧
使用 xdebug.profiler_output_name="cachegrind.out.%s" 的目的是生成类似cachegrind.out._home_httpd_html_test_xdebug_test_php的文件名,方便调试,因为我是在一个百万级别网站上使用,产生的文件很多很多,如果不这么做,很不方便
6 设置文件权限
mkdir -p /tmp/xdebug
chmod 755 /tmp/xdebug
chown nobody:nobody /tmp/xdebug
7 重启apache
8 分析php
WinCacheGrind下载地址:http://sourceforge.net/projects/wincachegrind/
将/tmp/xdebug下面 cachegrind.out.*_php 文件下载到windows下面分析吧
安装配置
下载PHP的XDebug扩展,网址:http://xdebug.org/
在Linux下编译安装XDebug
老办法
1 phpize
2 ./configure --enable-xdebug
3 make
4 复制modules/xdebug.so 到php的ext目录
5 编辑php.ini,在最下方增加
zend_extension_ts="/opt/php5/xdebug.so"
xdebug.profiler_enable=on
xdebug.trace_output_dir="/tmp/xdebug"
xdebug.profiler_output_dir="/tmp/xdebug"
xdebug.profiler_output_name="cachegrind.out.%s"
注意:xdebug.profiler_output_name 这一步折腾了很久,直接copy文档的说明吧
引用
xdebug.profiler_output_name
Type: string, Default value: cachegrind.out.%p
This setting determines the name of the file that is used to dump traces into. The setting specifies the format with format specifiers, very similar to sprintf() and strftime(). There are several format specifiers that can be used to format the file name.
See the xdebug.trace_output_name documentation for the supported specifiers.
Type: string, Default value: cachegrind.out.%p
This setting determines the name of the file that is used to dump traces into. The setting specifies the format with format specifiers, very similar to sprintf() and strftime(). There are several format specifiers that can be used to format the file name.
See the xdebug.trace_output_name documentation for the supported specifiers.
引用
xdebug.trace_output_name
Type: string, Default value: trace.%c
This setting determines the name of the file that is used to dump traces into. The setting specifies the format with format specifiers, very similar to sprintf() and strftime(). There are several format specifiers that can be used to format the file name. The '.xt' extension is always added automatically.
The possible format specifiers are:
Specifier Meaning Example Format Example Filename
%c crc32 of the current working directory trace.%c trace.1258863198.xt
%p pid trace.%p trace.5174.xt
%r random number trace.%r trace.072db0.xt
%s script name2 cachegrind.out.%s cachegrind.out._home_httpd_html_test_xdebug_test_php
%t timestamp (seconds) trace.%t trace.1179434742.xt
%u timestamp (microseconds) trace.%u trace.1179434749_642382.xt
%H $_SERVER['HTTP_HOST'] trace.%H trace.kossu.xt
%R $_SERVER['REQUEST_URI'] trace.%R trace._test_xdebug_test_php_var=1_var2=2.xt
%S session_id (from $_COOKIE if set) trace.%S trace.c70c1ec2375af58f74b390bbdd2a679d.xt
%% literal % trace.%% trace.%%.xt
Type: string, Default value: trace.%c
This setting determines the name of the file that is used to dump traces into. The setting specifies the format with format specifiers, very similar to sprintf() and strftime(). There are several format specifiers that can be used to format the file name. The '.xt' extension is always added automatically.
The possible format specifiers are:
Specifier Meaning Example Format Example Filename
%c crc32 of the current working directory trace.%c trace.1258863198.xt
%p pid trace.%p trace.5174.xt
%r random number trace.%r trace.072db0.xt
%s script name2 cachegrind.out.%s cachegrind.out._home_httpd_html_test_xdebug_test_php
%t timestamp (seconds) trace.%t trace.1179434742.xt
%u timestamp (microseconds) trace.%u trace.1179434749_642382.xt
%H $_SERVER['HTTP_HOST'] trace.%H trace.kossu.xt
%R $_SERVER['REQUEST_URI'] trace.%R trace._test_xdebug_test_php_var=1_var2=2.xt
%S session_id (from $_COOKIE if set) trace.%S trace.c70c1ec2375af58f74b390bbdd2a679d.xt
%% literal % trace.%% trace.%%.xt
使用 xdebug.profiler_output_name="cachegrind.out.%s" 的目的是生成类似cachegrind.out._home_httpd_html_test_xdebug_test_php的文件名,方便调试,因为我是在一个百万级别网站上使用,产生的文件很多很多,如果不这么做,很不方便
6 设置文件权限
mkdir -p /tmp/xdebug
chmod 755 /tmp/xdebug
chown nobody:nobody /tmp/xdebug
7 重启apache
8 分析php
WinCacheGrind下载地址:http://sourceforge.net/projects/wincachegrind/
将/tmp/xdebug下面 cachegrind.out.*_php 文件下载到windows下面分析吧



0 Responses