1.下载xhprof包:

wget http://pecl.php.net/get/xhprof-0.9.4.tgz

2.解压 进入扩展目录

tar zxvf xhprof-0.9..tgz

cd /home/justphp/xhprof-0.9./extension

3.使用phpize在当前目录编译源码

*由于我使用的事apt-get 安装的php环境 此时发展根本找不到phpize工具, 于是还得 安装php开发包php5-dev

 php5-dev是用来开发php扩展的,提供一些用来开发、编译php5扩展程序的必要php组件

apt-get install php5-dev //先安装php开发包

/usr/bin/phpize    //在xfprof扩展目录运行 生成源文件
./configure --with-php-config=/usr/bin/php-config  //生成配置文件

4.编译

直至扩展目录信息提示: Installing shared extensions: /usr/lib/php5/20121212/

5.配置php.ini

vim  /etc/php5/fpm/php.ini

添加:

[xhprof]
extension=/usr/lib/php5//xhprof.so;
;extension=xhprof.so;
; directory used by default implementation of the iXHProfRuns
; interface (namely, the XHProfRuns_Default class) for storing
; XHProf runs.
;
;xhprof.output_dir=<directory_for_storing_xhprof_runs>
xhprof.output_dir=/tmp/xhprof

6.重启php 生效xhprof扩展

/etc/init.d/php5-fpm restart

重启过多次 发现phpinfo中都没发现xhprof, 最后重启系统 才搞定!

7.安装图形绘制工具软件

 apt-get install graphviz

8.应用到php项目 进行性能测试

xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);

#这里是项目代码 最好放在入口文件

$data = xhprof_disable();

include_once "xhprof_lib/utils/xhprof_lib.php";  //xhprof源码包中文件 -->/home/justphp/xhprof-0.9.4/xhprof_lib/utils/xhprof_lib.php
include_once "xhprof_lib/utils/xhprof_runs.php"; //xhprof源码包中文件 -->/home/justphp/xhprof-0.9.4/xhprof_lib/utils/xhprof_runs.php
$objXhprofRun = new XHProfRuns_Default();//数据会保存在php.ini中xhprof.output_dir设置的目录去中  

$run_id = $objXhprofRun->save_run($data, "test");

9.结果

参考:http://www.cnblogs.com/wangtao_20/archive/2013/09/13/3320497.html

Ubuntu14.04下 安装xhprof的更多相关文章

  1. Ubuntu14.04下安装Hadoop2.5.1 (单机模式)

    本文地址:http://www.cnblogs.com/archimedes/p/hadoop-standalone-mode.html,转载请注明源地址. 欢迎关注我的个人博客:www.wuyudo ...

  2. 二、Ubuntu14.04下安装Hadoop2.4.0 (伪分布模式)

    在Ubuntu14.04下安装Hadoop2.4.0 (单机模式)基础上配置 一.配置core-site.xml /usr/local/hadoop/etc/hadoop/core-site.xml ...

  3. Ubuntu14.04下安装Flash Player

    Ubuntu14.04下安装Flash Player youhaidong@youhaidong:~$ sudo apt-get install flashplugin-nonfree [sudo] ...

  4. Ubuntu14.04下 安装p4c

    参考: Github p4c README Ubuntu14.04下 安装p4c 这里提供一个直接安装p4c的脚本:install_p4c.sh. 1.git clone下来p4c: $ git cl ...

  5. Ubuntu14.04下安装Libsvm,并使用Libsvm

    (1)Ubuntu14.04下安装Libsvm 转载:https://blog.csdn.net/katrinawj/article/details/78915874 一.下载: 网址:http:// ...

  6. ubuntu14.04下安装ffmpeg

    ubuntu14.04下安装ffmpeg 一.安装各种依赖包 1.yasm(libx264需要依赖yasm) sudo apt-get install yasm 2.libx264 sudo apt- ...

  7. ubuntu14.04下安装cudnn5.1.3,opencv3.0,编译caffe及配置matlab和python接口过程记录

    已有条件: ubuntu14.04+cuda7.5+anaconda2(即python2.7)+matlabR2014a 上述已经装好了,开始搭建caffe环境. 1. 装cudnn5.1.3,参照: ...

  8. 在Ubuntu14.04下安装Docker CE(1) - repository篇

    从2017年3月开始,Docker开始分为社区版本和企业版,也就是Docker CE和Docker EE, 原来Ubuntu14.04下,通过sudo apt-get install docker.i ...

  9. ubuntu14.04下安装爬虫工具scrapy

    scrapy是目前准备要学习的爬虫框架,其在ubuntu14.04下的安装过程如下: ubuntu14.04下默认安装了2.7的python以及setuptools,若未安装,可通过下面指令安装: s ...

随机推荐

  1. li布局问题

    问题示意,好多网站一般都有这种布局,如 问题主要原因,第一个li没有margin-left 其余有(这里只考虑一排的情况) 第一种解决方式: <!DOCTYPE html> <htm ...

  2. 自己设计代理IP池

    大体思路 使用redis作为队列,买了一份蘑菇代理,但是这个代理每5秒可以请求一次,我们将IP请求出来,从redis列表队列的左侧插入,要用的时候再从右侧取出,请求成功证明该IP是可用的,将该代理IP ...

  3. Linux USB 摄像头驱动

    在 cortex-a8 中,可接入摄像头的接口通常可以分为两种, CAMERA 接口和 USB 接口的摄像头.这一章主要是介绍 USB 摄像头的设备驱动程序.在我们印象中,驱动程序都是一个萝卜一个坑, ...

  4. PHP for和foreach的区别

    首先,我们先准备两个用于遍历的数组: $arr1=array(1=>'a', 3=>22, 5=>'b', 4=>'c', 8=>'d'); $arr2=array('a ...

  5. Histogram

    folly/Histogram.h Classes Histogram Histogram.h defines a simple histogram class, templated on the t ...

  6. 显示本月日历demo

    import java.text.DateFormatSymbols; import java.util.Calendar; import java.util.GregorianCalendar; p ...

  7. TCP 三次握手 四次握手

    http://blog.chinaunix.net/uid-22312037-id-3575121.html http://www.centos.bz/2012/08/tcp-establish-cl ...

  8. Python Twisted系列教程21: Twisted和Haskell

    作者:dave@http://krondo.com/twisted-and-haskell/  译者: Cheng Luo 你可以从”第一部分 Twist理论基础“开始阅读:也可以从”Twisted ...

  9. HALCON中的算子大全(中英对照)

    HALCON中的算子大全(中英对照) Chapter 1 :Classification1.1 Gaussian-Mixture-Models1.add_sample_class_gmm功能:把一个训 ...

  10. spring-boot-starter-security Spring Boot中集成Spring Security

    spring security是springboot支持的权限控制系统. security.basic.authorize-mode 要使用权限控制模式. security.basic.enabled ...