用xhprof来查看性能变化实在是php开发必备工具,就把自己安装使用的过程分享给大家。也算是自己的笔记。
-
前面的扩展的安装都太普遍就不截图了。
不解释,先下载解压:
wget http://pecl.php.net/get/xhprof-0.9.4.tgz
tar zxvf xhprof-0.9.4.tgz
-
需要注意,需要进入到extension目录里执行phpize
cd xhprof-0.9.4/extension/
phpize
-
但是 我在执行 phpize 遇到一个问题
-
提示cannot find autoconf 然后我使劲谷歌 终于知道了问题的所在 便使用了最暴力的办法 brew install autoconf 来解决这个问题
-
/configure --enable-xhprof ./configure --with-php-config=/Application/MAMP/bin/php/php5.6.10/bin/php-config 注意 config =后面的参数所指你的PHP安装目录
-
最后make
-
make install
-
如果你安装成功 便会有 Installing shared extensions: /Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug-non-zts-20131226/ 这样的提示
-
打开你的ini 文件
-
[xhprof]
MAMP_Xhprof_MAMP
extension=xhprof.so
xhprof.output_dir=/tmp/yhh -
如果 你安装xhprof成功 打开PHPinfo 发现没有加载成功 那就有可能 你下载的xhprof 扩展版本 与你当前PHP 版本无法匹配 打开error 日志文件
-
出现这样的 [07-Feb-2017 16:45:02 Asia/Shanghai] PHP Warning: PHP Startup: xhprof: Unable to initialize module
Module compiled with module API=20131226
PHP compiled with module API=20121212
These options need to match 那边是xhprof 扩展版本 与你当前PHP 版本无法匹配