Installation and Use of PHP performance monitoring software xhprof (original)
Author: Yu Chao Email: yuchao86@gmail.com
Xhprof is a lightweight PHP performance analysis tool open-source by Facebook, similar to xdebug. Compared with xdebug, the configuration is simpler, lighter, and more controllable.
Environment: Linux + PHP + Apache
1. Install xhprof
// Download to any directory
[Yuchao @ yuchao-Latitude-E5410 Dev] $ wget http://pecl.php.net/get/xhprof-0.9.2.tgz
// Decompress the file
[Yuchao @ yuchao-Latitude-E5410 Dev] $ tar zxf xhprof-0.9.2.tgz
// Enter the decompressed folder
[Yuchao @ yuchao-Latitude-E5410 Dev] $ CD xhprof-0.9.2
// Copy the two xhprof_html xhprof_lib folders to your webroot directory. The author is/opt/lampp/htdocs.
[Yuchao @ yuchao-Latitude-E5410 Dev] $ CP-r xhprof_html xhprof_lib/opt/lampp/htdocs/xhprof
// Enter the extension folder
[Yuchao @ yuchao-Latitude-E5410 Dev] $ CD Extension
// Execute phpize (the author's phpize is in/user/local/PHP/bin/phpize)
/User/local/PHP/bin/phpize
[Yuchao @ yuchao-Latitude-E5410 extension] $ pwd
/Home/yuchao/dev/xhprof-0.9.2/extension
[Yuchao @ yuchao-Latitude-E5410 extension] $ phpize
[Yuchao @ yuchao-Latitude-E5410 extension] $ ls
Acinclude. m4 config. guess config. m4 configure libtool Makefile. global modules xhprof. c
Aclocal. m4 config. h config. nice configure. in ltmain. sh Makefile. objects php_xhprof.h xhprof. la
Autom4te. cache config. h. in config. status include Makefile missing run-tests.php xhprof. lo
Build config. Log config. sub install-SH makefile. fragments mkinstalldirs tests
[Yuchao @ yuchao-Latitude-E5410 extension] $
[Yuchao @ yuchao-Latitude-E5410 Dev] $./configure
[Yuchao @ yuchao-Latitude-E5410 Dev] $ make
[Yuchao @ yuchao-Latitude-E5410 Dev] $ make test
[Yuchao @ yuchao-Latitude-E5410 Dev] $ sudo make install
After xhprof is installed, you will see the compiled/usr/local/PHP/lib/PHP/extensions/no-debug-non-zts-20060613/xhprof. So Module
Next, we need to configure PHP. ini so that PHP can load the xhprof. So module compiled by xhprof, and add the following to PhP. ini:
[Xhprof]
Extension = xhprof. So
Xhprof. output_dir =/opt/lampp/var/xhprof/
Note: xhprof. output_dir indicates the directory where the xhprof analysis result is stored.
Now let's test:
The examples directory contains sample. php,
Then run http: // localhost/xhprof/examples/sample. php to generate analysis logs under/opt/lampp/var/xhprof /.
In the 4e6011616b797. xhprof_foo file name, "4e6011616b797" indicates that the logo is changed, that is, the legendary id is changed, and "xhprof_foo" indicates the file suffix.
View the analyzed data
For example, for the data log generated just now, the url address is http: // localhost/xhprof_html/index. php? Run = 4e6038516b797 & source = xhprof_foo
In this way, you will see the statistical data,
Of course, there is also a graphical interface, please Google it yourself.