{"id":19849305,"url":"https://github.com/52fhy/yphp","last_synced_at":"2026-04-09T18:09:04.387Z","repository":{"id":84927799,"uuid":"120462749","full_name":"52fhy/yphp","owner":"52fhy","description":null,"archived":false,"fork":false,"pushed_at":"2018-03-04T08:37:23.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-11T12:48:25.849Z","etag":null,"topics":["docker","nginx","php","php7"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/52fhy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-06T13:41:06.000Z","updated_at":"2018-03-04T07:41:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"4179eab2-69b3-416f-b7ab-8c263ae663bb","html_url":"https://github.com/52fhy/yphp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/52fhy%2Fyphp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/52fhy%2Fyphp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/52fhy%2Fyphp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/52fhy%2Fyphp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/52fhy","download_url":"https://codeload.github.com/52fhy/yphp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241228735,"owners_count":19930663,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","nginx","php","php7"],"created_at":"2024-11-12T13:20:04.417Z","updated_at":"2025-12-31T01:11:28.052Z","avatar_url":"https://github.com/52fhy.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yphp\n\n该项目包含两部分：\n- 标准配置文件(php,nginx)\n- yphp脚本\n\n结合 [docker-images](https://github.com/52fhy/docker-images) 可以实现使用docker快速部署开发环境。下面针对使用场景进行示例说明。\n\n\n环境要求：\n\n- docker \n- git \n\nMac、Windows可以使用 `docker-machine` 部署docker，Ubuntu直接可以安装docker。\n\n准备工作：  \n1、安装好docker环境，安装并配置好git。  \n2、宿主机新建 `/work` 目录，Mac、Windows需要在Virtaul Box里配置共享文件夹 `/work` 到 虚拟机里面。`/work` 用于映射到容器里面。  \n3、获取 [docker-images](https://github.com/52fhy/docker-images) 里的 php56-fpm-centos68-withext 和 php71-fpm-centos68-phalcon-withext 镜像。  \n4、克隆 yphp 项目到 `/work` 目录。后续克隆自己的项目到 `/work/www/` 目录。  \n\n## 快速部署php5+php7+nginx开发环境\n\ndocker 创建并运行 php5+php7+nginx 容器:\n``` bash\ndocker run -d --restart=always --name yphp56  -p 9000:9000 \\\n     -v /work/:/work/  \\\n     -v \"/work/yphp/php/etc56/\":/usr/local/php/etc/  \\\n     php56-fpm-centos68-withext\n     \ndocker run -d --restart=always --name yphp71  -p 9001:9000 \\\n     -v /work/:/work/  \\\n     -v \"/work/yphp/php/etc/\":/usr/local/php/etc/  \\\n     php71-fpm-centos68-phalcon-withext\n\ndocker run -d --restart=always --name some-nginx -p 80-90:80-90 --link yphp56 --link yphp \\\n     -v /work/:/work/ \\\n     -v /work/yphp/nginx/conf/:/etc/nginx/ \\\n     -v /work/yphp/nginx/logs/:/etc/nginx/logs/ \\\n     daocloud.io/library/nginx:1.12.2-alpine\n```\n\n`--restart=always`用于每次docker服务启动后自动运行这些容器。\n\n使用`docker ps`可以查看容器运行状态：\n``` \ndocker@default:~$ docker ps\nCONTAINER ID        IMAGE                                     COMMAND                  CREATED             STATUS              PORTS                            NAMES\n796252980bde        daocloud.io/library/nginx:1.12.2-alpine   \"nginx -g 'daemon of…\"   20 hours ago        Up About an hour    0.0.0.0:80-90-\u003e80-90/tcp         some-nginx\n2835123c6d45        php71-fpm-centos68-phalcon-withext        \"/run.sh\"                20 hours ago        Up About an hour    80/tcp, 0.0.0.0:9001-\u003e9000/tcp   yphp71\n0e02a3049ba4        php56-fpm-centos68-withext                \"/run.sh\"                20 hours ago        Up About an hour    80/tcp, 0.0.0.0:9000-\u003e9000/tcp   yphp56\n```\n`STATUS` 为 `Up` 则说明正常。\n\n宿主机需要配置 hosts:\n```\n192.168.99.100  hello.cc hello56.cc hello71.cc  ysapi.cc\n```\n如果你是使用docker-machine部署的docker，`192.168.99.100`是虚拟机`default`默认的IP，宿主机IP是`192.168.99.1`。我们需要借助虚拟机服务容器提供的服务。  \n如果你是Ubuntu系统，那么可以直接运行docker服务，无需借助虚拟机，那么 hosts里直接写`127.0.0.1`即可。  \n\n\u003e使用docker-machine，流程是：宿主机运行虚拟机`default`，虚拟机提供docker环境。我们在虚拟机`default`运行容器，容器对虚拟机暴露端口。我们想要在宿主机访问容器里的访问，必须使用虚拟机`default`的IP才行。  \n\n这时候，我们访问 http://hello56.cc/ 可以看到返回的phpinfo信息。如果返回 nginx 404，请按照 http://www.cnblogs.com/52fhy/p/8468791.html 检查原因。  \n\n接下来需要配置php.ini扩展部分。  \n因为我们使用 `/etc` 覆盖了容器内的 php 配置，所以需要重新配置 php.ini：\n```\nextension=redis.so\nextension=swoole.so\nextension=yar.so\nextension=phalcon.so\nextension=seaslog.so\nextension=gearman.so\nextension=mongodb.so\nextension=tideways.so\nextension=protobuf.so\nextension=msgpack.so\n```\n\n按需开启。配置成功后，需要在 虚拟机`default` 运行 (假设修改的yphp56容器)：\n```\ndocker exec yphp56 killall php-fpm\ndocker exec yphp56 php-fpm\n```\n\n重新刷新 http://hello56.cc/ 看看效果。\n\n如果需要修改 nginx 配置，修改后请重启 nginx 服务：\n```\ndocker exec some-nginx nginx -s reload\n```\n\n如果需要配置xdebug，yphp71 安装起来很简单：\n```\ndocker exec yphp71 pecl install xdebug\n```\n然后修改宿主机 /work/yphp/php/etc/php.ini, 增加：\n```\n[xdebug]\nzend_extension=xdebug.so\nxdebug.enable=1\nxdebug.remote_enable=1\nxdebug.remote_connect_back=1\n; IDE所在机器IP\nxdebug.remote_host=192.168.99.1\n; IDE里监听的端口\nxdebug.remote_port=19001\nxdebug.remote_log=/var/log/xdebug_remote.log\n```\n\n重启 yphp71 容器即可。对于 yphp56 , 需要指定版本号：\n```\ndocker exec yphp56 pecl install xdebug-2.5.5\n```\n去 pecl.php.net 可以查看支持的版本号。\n\n## 关于yphp使用\n\nyphp只是对上面命令行的一些包装，具体可以查看 yphp.sh 代码。\n\n当挂载本地配置的时候，可以直接将yphp里的配置映射到容器内：\n``` bash\ndocker run -d --name ysphp -p 9001:9000 -p 8082:80 \\\n\t -v /work/:/work/  \\\n\t -v \"/work/yphp/php/etc/php.ini\":/usr/local/php/etc/php.ini  \\\n\t -v \"/work/yphp/nginx/conf/nginx.conf\":/usr/local/nginx/conf/nginx.conf  \\\n\t -v \"/work/yphp/nginx/conf/vhost/\":/usr/local/nginx/conf/vhost/  \\\n\t -v \"/work/yphp/nginx/logs/\":/usr/local/nginx/logs/  \\\n\t php71-fpm-centos68-phalcon-withext\n```\n\nnginx.conf配置默认会加载vhost目录配置，也可以只映射`/usr/local/nginx/conf/vhost/`：\n``` bash\ndocker run -d --name ysphp -p 9001:9000 -p 8082:80 \\\n\t -v /work/:/work/  \\\n\t -v \"/work/yphp/nginx/conf/vhost/\":/usr/local/nginx/conf/vhost/  \\\n\t php71-fpm-centos68-phalcon-withext\n```\n\n注意：`/yphp/php/etc/php.ini`默认是7.1.12版本的。后续如果添加了其它版本，文件名我会加上版本号。\n\nyphp提供了php71-fpm-centos68镜像内php、nginx配置文件目录的拷贝，且提供了yphp.sh脚本。\n\nyphp.sh脚本提供了常用命令：\n\n``` bash\n$ sh yphp.sh\nUsage: yphp.sh init | ps | ssh | rm | rm_all | nginx_reload | php_m | ip\n```\n\n- init 一键创建并运行容器\n- ps 查看容器内状态\n- ssh 进入容器\n- rm 停止并删除当前容器\n- rm_all 停止并删除所有容器\n- nginx_reload 容器内nginx重启，用于修改了nginx配置\n- php_m 查看容器内php的扩展\n- ip 查看当前环境IP地址（不是容器内）\n\n当前容器指的是容器名称带有`phalcon-withext`的容器。后续再完善。\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F52fhy%2Fyphp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F52fhy%2Fyphp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F52fhy%2Fyphp/lists"}