Skip to content

Docker 的 LNMP 一键安装开发环境与 PHP 非侵入式监控平台 xhgui 的安装使用 #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
guanguans opened this issue Jun 26, 2019 · 8 comments
Labels
2019 2019 Docker Docker Nginx Nginx PHP PHP

Comments

@guanguans
Copy link
Owner

guanguans commented Jun 26, 2019

Docker 的 LNMP 一键安装开发环境与 PHP 非侵入式监控平台 xhgui 的安装使用

安装之前请确保安装了以下软件

  • Docker
  • Docker-compose
  • Git
  • Composer

安装 dnmp-plus

$ git clone https://github.com/guanguans/dnmp-plus.git --recursive
$ cd dnmp-plus
$ cp env.sample .env
$ cp docker-compose-sample.yml docker-compose.yml
$ docker-compose up

默认 web 根目录 www/localhost/,浏览器访问 http://localhost

安装使用 xhgui

安装

$ cd www/xhgui-branch
$ composer install

修改 xhgui-branch 配置文件 www/xhgui-branch/config/config.default.php

<?php
return array(
    ...
    'debug'        => true, // 改为true,便于调试
    'mode'         => 'development',
    ...
    'extension'    => 'tideways', // 改为支持 PHP7 的 tideways
    ...
    'save.handler' => 'mongodb',
    'db.host'      => 'mongodb://mongo:27017', // 127.0.0.1 改为 mongo
    ...
);

hosts 文件中增加

127.0.0.1             xhgui.test

浏览器访问 http://xhgui.test

安装一个 laravel 项目作为要性能追踪及分析的项目使用示例

$ cd www/
$ composer create-project laravel/laravel
$ ./artisan make:auth

配置 laravel 的 nginx 配置

$ cd conf/conf.d/
$ cp laravel.conf.sample laravel.conf

修改 laravel.conf 为

...
location ~ \.php$ {
    fastcgi_pass   php72:9000;
    fastcgi_index  index.php;
    include        fastcgi_params;
    fastcgi_param  PATH_INFO $fastcgi_path_info;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    # 在执行主程序之前运行我们指定的PHP脚本
    fastcgi_param  PHP_VALUE "auto_prepend_file=/var/www/html/xhgui-branch/external/header.php"; 
}
...

hosts 文件中增加

127.0.0.1             laravel.test

重启 nginx

$ docker-compose restart nginx

浏览器访问 http://laravel.test, 再访问 http://xhgui.test,愉快的查看 laravel 项目的性能追踪及分析吧

@guanguans guanguans added Docker Docker PHP PHP labels Jun 26, 2019
@guanguans guanguans changed the title Docker+Nginx+MySQL+PHP(xhprof、tideways)+ Redis+MongDB+xhgui,PHPer 的一键安装式终极 debug 开发环境的安装与使用 dnmp-plus = Docker+Nginx+MySQL+PHP(xhprof、tideways)+ Redis+MongDB+xhgui,PHPer 的一键安装式终极 debug 开发环境的安装与使用 Jun 26, 2019
@guanguans guanguans changed the title dnmp-plus = Docker+Nginx+MySQL+PHP(xhprof、tideways)+ Redis+MongDB+xhgui,PHPer 的一键安装式终极 debug 开发环境的安装与使用 Docker 的 LNMP 一键安装开发环境与 PHP 非侵入式监控平台 xhgui(优化系统性能、定位 Bug 神器)的安装使用 Jun 28, 2019
@guanguans guanguans added the Nginx Nginx label Jun 28, 2019
@meilunzhi
Copy link

能加一个php7.1 7.3吗

@guanguans
Copy link
Owner Author

@summermagic 可以加的,我抽个时间加下。

@guanguans
Copy link
Owner Author

@all-contributors please add @summermagic for ideas

@allcontributors
Copy link
Contributor

@guanguans

I've put up a pull request to add @summermagic! 🎉

@guanguans guanguans changed the title Docker 的 LNMP 一键安装开发环境与 PHP 非侵入式监控平台 xhgui(优化系统性能、定位 Bug 神器)的安装使用 Docker 的 LNMP 一键安装开发环境与 PHP 非侵入式监控平台 xhgui 的安装使用 Jul 16, 2019
@meilunzhi
Copy link

[RuntimeException]
Could not scan for classes inside "/home/vagrant/code/xhgui-branch/vendor/phpunit/phpunit/PHPUnit/" which does not appear to be a file nor a folder

这个好像是composer 有问题

@guanguans
Copy link
Owner Author

@summermagic 更新下 composer 版本试试,运行 composer install --no-dev 试试。我这边测试是没问题的。

@ConserveLee
Copy link

mongo提示No suitable servers found (serverSelectionTryOnce set): [connection timeout calling ismaster on 'mongo:27017'],重构完也没用
一直restarting

@guanguans
Copy link
Owner Author

@ConserveLee

  1. 把 docker cpu、内存等值提高一些,重启 mongo 服务试试。

  1. 把 mongo 的镜像、容器、挂载目录、网络等都移除干净再次重新构建。可借助可视化工具移除,如vscode 的 docker 插件或者 kitematic。

@guanguans guanguans added the 2019 2019 label Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2019 2019 Docker Docker Nginx Nginx PHP PHP
Projects
None yet
Development

No branches or pull requests

3 participants