安裝以前確保已經正確安裝瞭如下軟件php
$ sudo pecl install mongodb
複製代碼
PHP 配置文件中添加html
[mongodb]
extension=mongodb.so
複製代碼
常規編譯安裝nginx
$ git clone https://github.com/tideways/php-xhprof-extension.git
$ cd /path/php-xhprof-extension
$ phpize
$ ./configure
$ make
$ sudo make install
複製代碼
PHP 配置文件中添加laravel
[tideways]
extension=tideways_xhprof.so
; 不須要自動加載,在程序中控制就行
tideways.auto_prepend_library=0
; 頻率設置爲100,在程序調用時能夠修改
tideways.sample_rate=100
複製代碼
$ git clone https://github.com/laynefyc/xhgui-branch.git
$ cd xhgui-branch
$ php install.php
複製代碼
修改 xhgui-branch 配置文件git
<?php
return array(
...
'extension' => 'tideways_xhprof',
...
'save.handler' => 'mongodb',
'db.host' => 'mongodb://127.0.0.1:27017',
'db.db' => 'xhprof',
...
);
複製代碼
$ mongo
> use xhprof
> db.results.ensureIndex( { 'meta.SERVER.REQUEST_TIME' : -1 } )
> db.results.ensureIndex( { 'profile.main().wt' : -1 } )
> db.results.ensureIndex( { 'profile.main().mu' : -1 } )
> db.results.ensureIndex( { 'profile.main().cpu' : -1 } )
> db.results.ensureIndex( { 'meta.url' : 1 } )
複製代碼
server {
listen 80;
server_name xhgui.test;
root /Users/yaozm/Documents/wwwroot/xhgui-branch/webroot;
# access_log /usr/local/var/log/nginx/access.log;
error_log /usr/local/var/log/nginx/error.log;
location / {
try_files $uri $uri/ /index.php?$query_string;
index index.php index.html index.htm;
}
}
複製代碼
$ fastcgi_param PHP_VALUE "auto_prepend_file=/path/xhgui-branch/external/header.php";
複製代碼
參考配置github
server {
listen 80;
server_name laravel.test;
root /Users/yaozm/Documents/wwwroot/laravel/public;
# access_log /usr/local/var/log/nginx/access.log;
error_log /usr/local/var/log/nginx/error.log;
location / {
try_files $uri $uri/ /index.php?$query_string;
index index.php index.html index.htm;
}
# 添加 PHP_VALUE,告訴 PHP 程序在執行前要調用的服務
fastcgi_param PHP_VALUE "auto_prepend_file=/path/wwwroot/xhgui-branch/external/header.php";
}
複製代碼
; Automatically add files before PHP document.
; http://php.net/auto-prepend-file
auto_prepend_file = "/path/wwwroot/xhgui-branch/external/header.php"
複製代碼