>  기사  >  백엔드 개발  >  Tideways, xhprof 및 xhgui는 PHP용 비침해적 모니터링 플랫폼을 만듭니다.

Tideways, xhprof 및 xhgui는 PHP용 비침해적 모니터링 플랫폼을 만듭니다.

步履不停
步履不停원래의
2019-06-18 15:23:092431검색

Tideways, xhprof 및 xhgui는 PHP용 비침해적 모니터링 플랫폼을 만듭니다.

환경 준비

설치하기 전에 다음 소프트웨어가 올바르게 설치되었는지 확인하세요

  • PHP
  • Nginx
  • Mongodb

PHP 구성 파일에 PHP mongodb 확장

$ sudo pecl install mongodb

Add

[mongodb]
extension=mongodb.so
를 설치하세요

PHP Tieaways 확장 설치

정기 컴파일 및 설치

$ git clone https://github.com/tideways/php-xhprof-extension.git
$ cd /path/php-xhprof-extension
$ phpize
$ ./configure
$ make
$ sudo make install

추가

[tideways]
extension=tideways_xhprof.so
; 不需要自动加载,在程序中控制就行
tideways.auto_prepend_library=0
; 频率设置为100,在程序调用时可以修改
tideways.sample_rate=100

PHP 구성 파일에 xhgui-branch(중국어 버전 xhgui) 설치

$ git clone https://github.com/laynefyc/xhgui-branch.git
$ cd xhgui-branch
$ php install.php

xhgui-branch 구성 파일 수정

<?php
return array(
     ...
    &#39;extension&#39; => 'tideways_xhprof',
     ...
    'save.handler' => 'mongodb',
    'db.host' => 'mongodb://127.0.0.1:27017',
    'db.db' => 'xhprof',
     ...
);

mongodb 시작 및 설정 xhgui index, 명령은 다음과 같습니다.

$ 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 } )

xhgui 로컬 가상 호스트 구성 참조

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;
    }
}

분석할 사이트를 설정하려면 분석할 사이트의 nginx 구성에 다음 항목을 직접 추가한 후, 구성이 적용됩니다.

$ fastcgi_param PHP_VALUE "auto_prepend_file=/path/xhgui-branch/external/header.php";

참조 구성

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";
}

또는 PHP 구성 파일을 수정하여 PHP 프로그램에 실행 전에 호출할 서비스를 알릴 수도 있습니다.

; Automatically add files before PHP document.
; http://php.net/auto-prepend-file
auto_prepend_file = "/path/wwwroot/xhgui-branch/external/header.php"

더 많은 PHP 관련 기술 기사를 보려면 PHP 튜토리얼 컬럼을 방문하여 알아보세요. !

위 내용은 Tideways, xhprof 및 xhgui는 PHP용 비침해적 모니터링 플랫폼을 만듭니다.의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.