分享我这两天遇到的问题,希望对大家有启发,另外我们可以热心的帮助别人,感谢 @leo

问题:1#

homestead-7: Running: script: Restarting Nginx
==> homestead-7: Failed to restart php7.1-fpm.service: Unit php7.1-fpm.service not found.
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

这个时候是你的 box 的版本中不包含 php7,但是你的 homestead 却使用了 php7 模块。
解决办法:降低 homestead 版本或者升级 box 版本到大于 6.0
参考:https://learnku.com/docs/laravel/5.3/homestead#lau...

我自己的配置如下(注意前两行 box 和 version 找个地方是可以指定的。。。):



---
box: laravel/homestead
version: 0.5.0

ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/Code
      to: /home/vagrant/Code

sites:
    - map: test.zxy.com
      to: /home/vagrant/Code/mywork/blog/public

databases:
    - homestead

# blackfire:
#     - id: foo
#       token: bar
#       client-id: foo
#       client-token: bar

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp


问题 2:#

按照这个教程 https://learnku.com/docs/laravel/5.3/homestead#launching-the-vagrant-box 配置之后
配置 host 的时候一定要配置 homestead.yaml 中的 IP 到物理机器的 hosts 中

问题 3:#

homestead.yaml 的配置未生效呢?
参见 https://learnku.com/laravel/t/3474#reply17768 这个问题是我提的,困扰了我 2 天,在这里感谢 @leo,论坛中仅仅一个人回复了我。

问题产生的原因:应该是我开始启动 homestead 虚拟机的时候误操作,造成了另外一个问题,导致 homestead 文件夹下面的 Vagrantfile 丢失,然后呢
我自己用 Vagrant init 命令重新生产了一个。。。晕,这让我陷入了歧途。。。

解决:重新下载 homestead,直接运行 homestead up 命令,就可以了

下面是常用的 Homestead 命令:#

homestead up:该命令用于启动 Homestead 虚拟机,如果加上 --provision 选项那么添加的新站点会发布到虚拟机上。
homestead halt:关闭 Homestead 虚拟机。
homestead suspend:暂停 Homestead 虚拟机。
homestead resume:恢复暂停的 Homestead 虚拟机。
homestead edit:编辑 Homestead.yaml 文件,这会使用系统中与 .yaml 文件关联的任意编辑器。
homestead status:查看当前 Homestead 虚拟机的状态。

《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
讨论数量: 6

问题 1 的解决方法也可以解决当运行时候,本地 box 版本过低,导致,直接去下载,其实我们可以在 homestead.yaml 文件中制定版本的

8年前 评论

更新 1: 提示 homestead: SSH auth method: private key 之后 timeout 怎么办,全部日志如下:

Bringing machine 'homestead' up with 'virtualbox' provider...
==> homestead: Clearing any previously set network interfaces...
==> homestead: Preparing network interfaces based on configuration...
homestead: Adapter 1: nat
homestead: Adapter 2: hostonly
==> homestead: Forwarding ports...
homestead: 80 (guest) => 8000 (host) (adapter 1)
homestead: 443 (guest) => 44300 (host) (adapter 1)
homestead: 3306 (guest) => 33060 (host) (adapter 1)
homestead: 5432 (guest) => 54320 (host) (adapter 1)
homestead: 22 (guest) => 2222 (host) (adapter 1)
==> homestead: Running 'pre-boot' VM customizations...
==> homestead: Booting VM...
==> homestead: Waiting for machine to boot. This may take a few minutes...
homestead: SSH address: 127.0.0.1:2222
homestead: SSH username: vagrant
homestead: SSH auth method: private key
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

看了网上五花八门的回答,还是这个靠谱
https://laracasts.com/discuss/channels/lar...

解决方法:升级 VB,不过顺便也升级了下 Vagrant
我回想了我的操作,我是删除了旧 box 安装了新 box 之后出现的问题。

希望对大家有帮助。

8年前 评论

@meiyitian 升级不一定能解决问题。反而会导致问题。
我的机器 win7 64 除了 vb4.3.12 只要升级到比这个高的版本就无法启动机器。网上也有很多人和我一样情况,目前还没找到有效的方法。

对于这种私钥验证超时的,只要本机生成一个新的密钥对,然后把公钥拷贝到虚拟机就可以解决

8年前 评论

@meiyitian 这个问题我前天也遇到了,网上搜索各种办法。BIOS 虚拟化确定开了、公钥私钥重新生成、更换 vagrant 版本都试过。最后一条无聊的命令 vagrant reload 后就行了...

8年前 评论

@史沟飞 哈哈,看来的不听折腾,我觉得 如果记得在环境变坏之前我们做的操作会有助于解决问题

8年前 评论

@keer 这个因人而异,具体怎么操作,还得评估一下,您可以想一下 你那里是如何出现 异常情况的,以及之前做了啥操作。然后再对比网上的方案,选一个靠谱的方案执行。

8年前 评论