Homestead 2.0 安装笔记

说明

此文档为 Mac 版本 10.10 下安装 Homestead 2.0 的笔记, 要求阅读时对 Homestead 有一定的了解, Homestead 的说明请见 这里.

安装

1. 安装 Virtual Box

下载 (链接) 并安装 Virtual Box.

2. 安装 Vagrant

下载 (链接) 并安装 Vagrant.

3. 下载并添加 homestead box

命令行运行

$ vagrant box add laravel/homestead

输出

file

为了加快下载速度, CTRL+C 中断下载, 把上图剪头指向的链接利用多线程下载工具下载.

下载后执行以下命令, 修改 /path/to/virtualbox.box 为正确的 path.

$ vagrant box add laravel/homestead /path/to/virtualbox.box 

4. 安装 homestead 命令

composer global require "laravel/homestead=~2.0"

请确定 ~/.composer/vendor/bin 目录在你的 PATH 里面.

安装完成后执行以下命令进行测试:

homestead

配置和初始化

1. 初始化 homestead

$ homestead init

会生成 ~/.homestead/Homestead.yaml 文件

2. 配置 Homestead.yaml

运行以下命令进行 ~/.homestead/Homestead.yaml 文件的编辑

$ homestead edit

修改后保存:
file

3. 添加 hosts

执行以下命令

$ sudo vi /etc/hosts

追加

192.168.10.10    phphub.app

4. 初始化 homestead 虚拟机

$ homestead up

初始化完成后, 访问浏览器 http://phphub.app

其他信息

端口映射

本地地址 127.0.0.1 端口对应

  • SSH: 2222 → Forwards To 22
  • HTTP: 8000 → Forwards To 80
  • MySQL: 33060 → Forwards To 3306
  • Postgres: 54320 → Forwards To 5432

连接数据库

MySQL 和 Postgres 的认证为: homestead / secret

登录虚拟机

$ homestead ssh
摈弃世俗浮躁,追求技术精湛
本帖已被设为精华帖!
Summer
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 29
Summer

@zwl1619 你再 mark 我就得封号啦, 兄弟.

8年前 评论
Summer

@zwl1619 你可以用收藏功能 :sheep:

8年前 评论

5.0的应该怎么安装啊```

7年前 评论

折腾了一晚上,把环境搭建好了,但是访问Homestead.app的时候``
502 Bad Gateway
nginx/1.11.1

7年前 评论
冷无缺

@HectorChan 我开始安装的时候,也遇到了这个问题
http://blog.leanote.com/post/wuliang/54c6d... 这是当时解决的方法,希望对你有帮助

7年前 评论

@冷无缺 fpm配置文件的路径在哪里?

7年前 评论
冷无缺

@HectorChan

fpm 路径:/etc/php/7.0/fpm/pool.d

nginx配置文件路径: /etc/nginx/sites-enabled 下有个以你网站域名命名的文件

7年前 评论

@冷无缺 我有个疑惑,是在VM里面设置,还是本机上啊?

7年前 评论
冷无缺

@HectorChan

1、homestead up 先启动虚拟机

2、homestead ssh 连接到虚拟机,在虚拟机里边设置

7年前 评论

@HectorChan 你安装成功了没
有没有文档参考一下啊

7年前 评论

$ vagrant box add laravel/homestead https://atlas.hashicorp.com/laravel/boxes/...
==> box: Loading metadata for box 'https://atlas.hashicorp.com/laravel/boxes/...'
==> box: Adding box 'laravel/homestead' (v0.5.0) for provider: virtualbox
box: Downloading: https://atlas.hashicorp.com/laravel/boxes/...
box:
The box failed to unpackage properly. Please verify that the box
file you're trying to add is not corrupted and try again. The
output from attempting to unpackage (if any):

7年前 评论

@树哥 各位,我折腾一天了,始终出现上述错误

7年前 评论

$ vagrant box list
There are no installed boxes! Use vagrant box add to add some.
版本是 Vagrant 1.7.1

7年前 评论
幽弥狂

@HectorChan 我的改过了 还是报错 ,求帮助啊

7年前 评论

@冷无缺 求教,我按照你说的改过了,也 sudo service restart nginx重启了nginx,
但是启动的时候还是说Failed to restart php7.1-fpm.service: Unit php7.1-fpm.service not found

7年前 评论
冷无缺

@VShangxiao 你的php-fpm,重启失败了,报错日志,应该就能找到问题。估计你的路径还是不对

7年前 评论

@冷无缺 求问,我已经按照你那篇 提示文章将fastcgi_pass unix:/var/run/php7.1-fpm.sock; 改成了 fastcgi_pass unix:/var/run/php7.0-fpm.sock; 然后就sudo service nginx restart 重启了nginx,但是vagrant reload --provision之后还是显示php7.1-fpm: unrecognized service?快崩溃了……

7年前 评论
冷无缺

@VShangxiao 你装的PHP版本是7.1的吧,你现在改成了7.0的fpm,报错信息是找不到7.1的fpm。你先看看的PHP版本吧

7年前 评论

2017-03-30 一路安装OK,唯独http报502错误

后来在 /etc/nginx/sites-enabled/homestead.app 中发现php-fpm的sock文件引用错误。

原文是/var/run/php5-fpm.sock,很明显,都php7了,路径是不对的。

手动查询后调整为 /var/run/php/php7.1-fpm.sock,遂OK

后来就看到你的回复啦~~~

@HectorChan

6年前 评论
jasonjiang123

@Jamlee 你缺少第四行

ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
6年前 评论

升级 virtual Box 5.1 以后 vagrant就报错了~

6年前 评论

@大力 想问下,我修改的时候报出权限错误,你没有遇到这个问题吗?我是 vagrant 的身份

6年前 评论
Jourdon

F:\homestead>homestead init
[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "init" is not defined.

这是什么问题?
直接homestead 显示 的好像和正常安装的不一样。。是homestead 错了吗

file

6年前 评论

运行homestead up出现 stdin is not a tty 错误,是为什么呀?

6年前 评论

laravel这些文档我也是醉了

5年前 评论

真心醉了。homestead win10配置下一大堆错误。homestead装上了,又各种域名连不上。各种配置后都是连不上。解决方案都没有的论坛。。。。还敢说优雅的php框架????

4年前 评论
Summer (楼主) 4年前
Kimzzz (作者) 4年前

下载后并且add添加box后,去up依旧自动去下载box了 咋办

3年前 评论

这个怎么配置局域网访问啊?,这样改了 还是不行,启动报 NFS requires a host-only network to be created. Please add a host-only network to the machine (with either DHCP or a static IP) for NFS to work.

file

3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!