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=<directory_for_storing_xhprof_runs>
<directory_for_storing_xhprof_runs> This path refers to the folder where the generated data is placed, for example, in/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 This instruction will list the xhprof related paths, and you can query them all. ?
6. Copy the xhprof_html folder to the root of your Web server to access the generated files, and when the PHP is accessed, the <directory_for_storing_xhprof_runs> A index_1277956324.xhprof-like record file is generated under the directory, and the results are visible using a similar http://www.url.com/xhprof_html/index.php?run=index_1277956324. You can also http://www.url.com/xhprof_html/index.php access the file directory and select any one to view it.
CentOS installs PHP performance test tools with Yum Xhprof