php性能分析利器xhprof扩展安装(php5.6.31)
发布于 作者:苏南大叔 来源:程序如此灵动~
苏南大叔在本篇文章中,给大家要说的是,老牌的php性能分析利器xhprof
。不过这款利器,已经很多年没有更新了。本文的写作环境是php5.6.31
。截至到本文发布时为止,xhprof
的官方版本,并不支持php7
系列的性能分析。对于php7
下xhprof
的安装,请参见文末相关链接。
下载xhprof
源码
官方版本的源码下载地址是:http://pecl.php.net/package/xhprof 。
编译扩展
xhprof
的扩展编译和phptrace
等其他扩展的编译,过程基本类似。可能出现的问题也基本相同。大家可以参考一下,苏南大叔以前的扩展编译相关文章。
which php-config
cd xhprof-0.9.4/extension/
phpize
./configure --with-php-config=<php-config-path>
make && sudo make install
对于configure
命令中的php-config-path
,需要使用which php-config
命令的结果来代替即可。
注意对比一下,最终install
的地址是否是phpinfo()
里面的扩展目录地址。如果不是,可能需要主动复制一下才行。
修改php.ini
启用xhprof
[xhprof]
extension = xhprof.so
xhprof.output_dir = /tmp/xhprof
重启验证是否生效
phpinfo
中出现了xhprof
的相关信息,不过这个版本号似乎有些问题。从pecl.php.net
下载的0.9.4版本,编译后居然是0.9.2
版本号。在https://github.com/phacility/xhprof 下载到的也是0.9.2
版本。可能是官方忘了修改版本号了。
相关文章
写在最后
欢迎继续查看苏南大叔的后续xhprof
文章: https://newsn.net/tag/xhprof/ 。


