PHP性能分析工具xhprof安装及使用

分类:PHP, 发布于 2018-03-29 07:37:18  浏览(717)

对于本地开发环境来说,进行性能分析xdebug是够用了,但如果是线上环境的话,xdebug消耗较大,配置也不够灵活,因此线上环境建议使用xhprof进行PHP性能追踪及分析。

1、安装xhprof

git clone https://github.com/longxinH/xhprof
cd xhprof/extension/
phpize
./configure
make && make install


然后在/etc/php.d/中加入xhprof.ini,内容为extension=xhprof.so

重启php-fpm

为了更直观,可以安装图片组件

yum install graphviz

至此xhprof扩展安装完成,下面是使用过程:

在文件入口输入启用方法

xhprof_enable();

在结束位置添加

$xhprof_data = xhprof_disable();


include_once $_SERVER['DOCUMENT_ROOT']."/xhprof_lib.php";
include_once $_SERVER['DOCUMENT_ROOT']."/xhprof_runs.php";

$xhprof_runs = new \XHProfRuns_Default();


$run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_foo");

die("http://192.168.3.5/xhprof/xhprof_html/index.php?run=$run_id&source=xhprof_foo");


根据你的文件目录配置,点击以上地址查看分析结果

以下测试md5和sha1的结果:

image.png

1522308957892566.png

nginx配置https统一转到www域名

分类:Linux, 发布于 2018-03-15 05:47:47  浏览(609)

见如下配置 :

    server {
        listen       80;
        server_name zainboy.com,www.zainboy.com;
        return 301 https://www.zainboy.com$request_uri;
    }
    server {
        listen 443;
        server_name zainboy.com;
        return 301 https://www.zainboy.com$request_uri;
    }
    server {
        listen 443 default_server ssl;
        server_name  www.zainboy.com;
        # ssl配置
    }

主要在于最后的listen 443 default_server ssl; 不然会访问出错。

手动安装composer

分类:PHP, 发布于 2018-03-09 14:43:36  浏览(698)

在国内大家懂的,安装composer往往需要手动安装。

将composer.phar下载,放入php.exe同目录,在该目录下建立composer.bat文件,内容写入@php "%~dp0composer.phar" %*即可,再次开起cmd窗口,输入composer就可以了,确保添加了环境变量。