{"id":16314809,"url":"https://github.com/forecho/vagrant-ubuntu-php7","last_synced_at":"2025-07-09T01:33:46.983Z","repository":{"id":147509794,"uuid":"62877398","full_name":"forecho/vagrant-ubuntu-php7","owner":"forecho","description":"vagrant php 7.0 shell 脚本自动安装环境的方式","archived":false,"fork":false,"pushed_at":"2018-08-18T10:30:18.000Z","size":17,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-07T09:05:55.953Z","etag":null,"topics":["vagrant"],"latest_commit_sha":null,"homepage":"","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/forecho.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":"2016-07-08T09:33:53.000Z","updated_at":"2019-05-21T14:32:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"a4e1354b-cecb-46af-8aa3-edad872cb8a1","html_url":"https://github.com/forecho/vagrant-ubuntu-php7","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/forecho/vagrant-ubuntu-php7","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forecho%2Fvagrant-ubuntu-php7","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forecho%2Fvagrant-ubuntu-php7/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forecho%2Fvagrant-ubuntu-php7/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forecho%2Fvagrant-ubuntu-php7/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/forecho","download_url":"https://codeload.github.com/forecho/vagrant-ubuntu-php7/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forecho%2Fvagrant-ubuntu-php7/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264375618,"owners_count":23598415,"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":["vagrant"],"created_at":"2024-10-10T21:55:19.711Z","updated_at":"2025-07-09T01:33:46.966Z","avatar_url":"https://github.com/forecho.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"打造 vagrant php7 开发环境\n================\n\n## 包括以下环境和软件：\n\n- Nginx 1.4.6\n- Mysql 5.5.46（mysql -V）\n- PHP 7.0.8-3\n- git\n- [autojump](https://github.com/joelthelion/autojump)\n- [composer](https://getcomposer.org)\n- vim\n\n## Box地址\n\n链接: https://pan.baidu.com/s/1RFfeb89sad88Ug3_z0zoNQ 密码: xghe\n\n\n## 如何搭建\n\n先安装好 VirtualBox 和 vagrant 软件，推荐使用版本（上面的百度盘链接里面有提供以下 Windows7 版本）：\n\n - VirtualBox-4.3.10-93012-Win\n - vagrant_1.7.4\n \n下载 ubuntu_trusty_64.box, 执行以下命令添加刚才下载好的 box 到 Box list：\n\n```sh\n// cd 下载 box 目录\n// vagrant box add 名称 路径\nvagrant box add trusty64 ubuntu_trusty_64.box\n\nvagrant box list // 查看\nmkdir ubuntu // 创建文件夹\ngit clone https://github.com/forecho/vagrant-ubuntu-php7.git php7\ncd php7\n```\n然后启动 vagrant\n\n```\nvagrant up\n```\n\n最后你可以愉快的时候 Xshell 工具 SSH 连接了。\n\n```\nIP：192.168.33.10\n端口：22\n用户名：vagrant\n密码：vagrant\n```\n\n连接之后切换 root 用户：\n\n```\nsudo su // 不需要输入密码\n```\n\n## 关于 nginx 的使用\n\n默认这个 box 我已经配置好 LNMP 环境了。PHP 的项目直接放在当前文件夹的 `php` 文件夹内就可以了。（默认配置的是 php 文件夹，如果要换其他文件夹，请自行修改 nginx 的 dev.conf 文件的配置）\n\n示例：\n\n```\n根目录\n\t|--php\n\t\t|--cai\n\t\t\t|--zheng\n\t\t\t\t|--hai\n\t\t|--getyii\n\t\t\t|--frontend\n\t\t\t\t|--web\n```\n\n默认我使用的是 `*.dev.com` 作为域名。\n\n只要在**本机（一般是 Windows 系统）**的 hosts 文件，添加一下代码：\n\n```\n……\n192.168.33.10\tcai.dev.com\n192.168.33.10\tcai-zheng-hai.dev.com\n192.168.33.10\tgetyii-frontend-web.dev.com\n……\n```\n\n**注意**\n- 因为是虚拟机，所以添加 hosts 这一步是必须的。\n- 域名只做了三层解析，太多层觉得没必要。也就是说URL `cai-zheng-hai-open.dev.com` 默认是不行的。\n- **Windows 可以使用 Acrylic 软件让 host 支持通配符解析，参考文章：[支持通配符和正则表达式的hosts文件(本地dns缓存及代理)](https://blog.tianqitu.net/2014/11/22/hosts-that-support-wildcards-and-regular-expressions/)**\n- **Mac 可以使用 Dnsmasq 软件让 host 支持通配符解析，参考文章：[Mac OSX 安装 Dnsmasq 来加速网络](http://www.shixf.com/wiki/os/macosx/dnsmasq)**\n\n\n\n## 关于MySQL\n\n默认用户名：root\n\n默认密码：root\n\n\n## 关于一些常用的命令\n\n**PHP-FPM**\n\n- 重启\n```\nsudo service php7.0-fpm restart\n```\n- PHP 配置文件位置：`/etc/php/7.0/fpm/php.ini`\n- 查看 phpinfo() -\u003e http://test.dev.com/\n\n**Nginx**\n\n- 重启\n```sh\nsudo service nginx restart\n```\n\n- 修改虚拟空间配置文件：\n```\nsudo vim /etc/nginx/conf.d/default.conf\n```\n\n**MySQL**\n\n- 重启\n```sh\nsudo service mysql restart\n```\n\n\n## 常见问题\n\n\n**Mac 下使用虚拟机，运行项目的时候提示 「Permission denied」没有权限问题？**\n\n这个是因为 Nginx 、PHP 和 项目文件夹用户组不一致导致的问题，解决办法是：\n\n修改 nginx 用户组：\n\n```\n$ sudo vim /etc/nginx/nginx.conf\n```\n\n```\n# 修改为 vagrant\n# user  www-data;\nuser  vagrant;\n```\n\n修改 PHP 用户组：\n\n```\n$ sudo vim /etc/php/7.0/fpm/pool.d/www.conf\n```\n\n```\n; 修改用户为nginx\n; user = www-data\nuser = vagrant\n; 修改组为 vagrant\n; group = www-data\ngroup = vagrant\n\n\n; listen.owner = www-data\n; listen.group = www-data\n\nlisten.owner = vagrant\nlisten.group = vagrant\n```\n\n然后重启 Nginx 和 PHP\n\n```\n$ sudo service nginx restart\n$ sudo service php7.0-fpm restart\n```\n\n## 参考文档\n\n- [发现 Vagrant Boxes](https://app.vagrantup.com/boxes/search)\n- [路径（七）：用 Vagrant 管理虚拟机](http://ninghao.net/blog/2077)\n- [1.2 Vagrant安装配置](https://github.com/astaxie/Go-in-Action/blob/master/ebook/zh/01.2.md)\n- [forecho/vagrant-ubuntu-trusty-64](https://github.com/forecho/vagrant-ubuntu-trusty-64)\n- [How To Upgrade to PHP 7 on Ubuntu 14.04](https://www.digitalocean.com/community/tutorials/how-to-upgrade-to-php-7-on-ubuntu-14-04)\n- [解决Mac 下使用 vagrant 搭建 Yii2 生成 assets 提示 「Permission denied」没有权限问题](http://www.getyii.com/topic/153)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforecho%2Fvagrant-ubuntu-php7","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforecho%2Fvagrant-ubuntu-php7","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforecho%2Fvagrant-ubuntu-php7/lists"}