# PHP运行环境 **Repository Path**: coversky/pre ## Basic Information - **Project Name**: PHP运行环境 - **Description**: php runtime environment - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 3 - **Created**: 2021-01-12 - **Last Updated**: 2022-10-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 使用说明 > www-data用户和用户组在容器里面id为33,alpine下为82 > > mysql用户和用户组在容器里面id为999 ## 快速使用 **执行安装脚本:** ```shell // clone 仓库 git clone https://gitee.com/jmhc/pre.git // 执行安装脚本 bash sh/install.sh // or cd sh && bash install.sh ``` **执行脚本后:** ``` js // 输入序列号选择安装程序,多个使用英文逗号 `,` 隔开,全选输入 `all`,默认全部安装 Enter serial number to select setup program (multiple separated by `,`) [all] : 1.nginx 2.mongo 3.redis 4.rabbitmq 5.mysql(8.0.16) 6.mysql(latest) 7.php(5.6) 8.php(7.3) 9.php(7.4) 10.php(8.0) // 输入php使用的系统版本,docker版本20以下使用3.13,版本20以上可使用3.14 Please enter the php alpine version [3.13] : // 输入名称选择安装php扩展,多个使用英文逗号 `,` 隔开,全选输入 `all`,默认不安装扩展 Enter the php extension to install (multiple separated by `,`) [bcmath,bz2,curl,exif,gd,gettext,intl,mbstring,mongodb,mysql,mysqli,opcache,pcntl,pdo_mysql,pdo_sqlsrv,redis,sockets,zip] : bcmath,bz2,calendar,curl,exif,ffmpeg,gd,gettext,gifsicle,git,gmp,imagick,imap,inotify,intl,jpegoptim,ldap,mbstring,mcrypt,mongodb,mysql,mysqli,opcache,optipng,pcntl,pdo_mysql,phpcbf,phpcs,php-cs-fixer,phpmd,phpstan,pngquant,psalm,pspell,readline,redis,shmop,snmp,soap,sockets,sqlsrv,svgo,swoole,sysvmsg,sysvsem,sysvshm,tidy,wddx,webp,xhprof,xmlrpc,xsl,yaf,zip // 输入容器根目录名称,默认 `wwwroot` Please enter the root directory name [wwwroot] : // 是否覆盖已存在配置、环境变量、容器编排文件,默认不覆盖 Whether overwrite existing files [y/N] : // 安装提醒 Install remind : ==================================================================================================== Install the program : nginx Install the PHP extension : none Whether overwrite existing files : no Root directory : wwwroot ==================================================================================================== // 是否确认安装,默认安装,也可不安装自行修改 `.env` 文件后自行编排 Whether to start installation [Y/n] : ``` **安装成功后可直接删除 `samples` ,`sh` 目录** ## xhprof使用说明 > `xhprof` 是一款php性能分析扩展 > > 关于下文中一些变量说明: > > `*` 表示任意通配符 > > `${ROOT_DIR_NAME}` 替换成install.sh输入的根目录名称 > > `${CONTANER_NAME}` 替换成容器名称 ### 1.修改.env文件 > 在`PHP*_EXTENSIONS`后添加`xhprof` ### 2.安装完成执行 > 需提前安装git ```shell # 进入项目根目录下载ui cd ~/pre/www git clone https://github.com/laynefyc/xhgui-branch.git analysis # 调整目录权限 sudo chown -R 82:82 analysis/cache # 如果 php>=7,执行 sed -i "s;'extension' => 'xhprof';'extension' => 'tideways_xhprof';" analysis/config/config.default.php # 替换数据库地址 sed -i "s;'db.host' => 'mongodb://127.0.0.1:27017';'db.host' => 'mongodb://mongo:27017';" analysis/config/config.default.php # 如果mongodb存在密码验证 sed -i "s;'db.options' => array();'db.options' => array(\n 'db' => 'admin',\n 'username' => 'root'\n ,\n 'password' => '123456'\n );" analysis/config/config.default.php # 执行安装 docker exec -it -w /${ROOT_DIR_NAME}/www/analysis ${CONTANER_NAME} php install.php ``` ### 3.使用方式 > nginx location里配置 ``` fastcgi_param PHP_VALUE "auto_prepend_file=/${ROOT_DIR_NAME}/www/analysis/external/header.php"; ```