ngx_php7_tracker - 追踪 PHP7 运行的 Nginx 模块


BSD
Linux
C/C++

软件简介

ngx_php7_tracker

ngx_php7 的分支,追踪php7脚本运行的opcode、函数栈调用的nginx模块。

环境

- PHP 7.0.*
- nginx-1.6.3

安装

$ wget http://php.net/distributions/php-7.0.14.tar.gz
$ tar xf php-7.0.14.tar.gz
$ cd php-7.0.14

$ ./configure --prefix=/path/to/php \
              --enable-embed

$ make && make install


$ git clone https://github.com/rryqszq4/ngx_php7_tracker.git

$ wget 'http://nginx.org/download/nginx-1.6.3.tar.gz'
$ tar -zxvf nginx-1.6.3.tar.gz
$ cd nginx-1.6.3

$ export PHP_BIN=/path/to/php/bin
$ export PHP_INC=/path/to/php/include/php
$ export PHP_LIB=/path/to/php/lib

$ ./configure --user=www --group=www \
              --prefix=/path/to/nginx \
              --with-ld-opt="-Wl,-rpath,$PHP_LIB" \
              --add-module=/path/to/ngx_php7_tracker

$ make
$ make install

概要


user www www;
worker_processes  4;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    keepalive_timeout  65;
    
    client_max_body_size 10m;   
    client_body_buffer_size 4096k;

    php_ini_path /usr/local/php/etc/php.ini;

    server {
        listen       80;
        server_name  localhost;
    
        location /content_by_php {
            content_by_php '
                header("Content-Type: text/html;charset=UTF-8");
                require_once("/home/www/yaf/cg/output/Sample/index.php");
            ';
        }

        location /opcode_by_php {
            opcode_by_php '
                header("Content-Type: text/html;charset=UTF-8");
                require_once("/home/www/yaf/cg/output/Sample/index.php");
            ';
        }

        location /stack_by_php {
            stack_by_php '
                header("Content-Type: text/html;charset=UTF-8");
                require_once("/home/www/yaf/cg/output/Sample/index.php");
            ';
        }
    }
}

指令

opcode_by_php

stack_by_php