1. First we install the XHPROF: 
 
Yum Install Xhprof
 
 
2. After installation, find xhprof configuration file xhprof.conf, usually in/ETC/PHP.D, add these 2 lines:
 
Extension=xhprof.soxhprof.output_dir=
 
  
 
  This path refers to the folder where the generated data is placed, for example, in the/var/www/html/xhprof_data 
 
 
3. If you want a graphics session, you need to install dot (optional):
 
Yum Install Graphviz
 
 
4. Reboot the server after installation:
 
Service httpd Restart
 
 
5. Use as long as the following file code is included:
 
#在php的头部加上, you can set the recording frequency, such as record one of the xhprof_enable (xhprof_flags_cpu + xhprof_flags_memory);
 
#在代码页的底部加上if ($xhprof _flag) {    $xhprof _data = xhprof_disable ();    Include_once "./xhprof_lib/utils/xhprof_lib.php";    Include_once "./xhprof_lib/utils/xhprof_runs.php";    $xhprof _runs = new Xhprofruns_default ();    $xhprof _runs->save_run ($xhprof _data, ' xhprof ', "index_". Time ());
 
Above the xhprof_lib,php and xhprof_runs.php the path of the 2 files to change to their own path, do not write wrong, if you cannot find these two files, you can use the command Whereis xhprof the instructions will be xhprof related paths listed, You can check each one.
 
 
6. Copy the xhprof_html folder to the root of your Web server to access the generated files, and when there is access to the PHP, a  log file similar to Index_1277956324.xhprof is generated in the directory, using a similar http:// www.url.com/xhprof_html/index.php?run=index_1277956324, you can see the results. You can also http://www.url.com/xhprof_html/index.php access the file directory and select any one to view it.